Page 1 of 1

TestMemory(*mem)

Posted: Thu Aug 14, 2014 9:00 am
by NikitaOdnorob98
Please, add this function

Code: Select all

Procedure.b TestMemory(*Pointer) ;Only Windows
  Protected mbi.MEMORY_BASIC_INFORMATION
  Protected Result.b = #False, dwWrote
  
  dwWrote = VirtualQuery_(*Pointer, @mbi, SizeOf(MEMORY_BASIC_INFORMATION))
  If dwWrote
    If mbi\BaseAddress+mbi\RegionSize >= *Pointer+1
      If mbi\Protect & (#PAGE_READONLY | #PAGE_READWRITE | #PAGE_EXECUTE_READ | #PAGE_EXECUTE_READWRITE)
        Result = #True
      EndIf
    EndIf
  EndIf
  
  ProcedureReturn Result
EndProcedure

*mem = AllocateMemory(10)
If *mem
  Debug TestMemory(*mem)
  FreeMemory(*mem)
EndIf

*mem = Random(100000) ;Random value
Debug TestMemory(*mem)

Re: TestMemory(*mem)

Posted: Thu Aug 14, 2014 10:53 am
by graph100
it's not reliable.. 1 time over 5 it answers "1 1"

Re: TestMemory(*mem)

Posted: Thu Aug 14, 2014 11:07 am
by IdeasVacuum
A random test is of very little value. Tests need to be methodical, cover the entire RAM, mimic application loads, be CPU specific. If you want to test memory Memtest86+: http://www.memtest.org/