Page 1 of 1

Memory Stress Testing

Posted: Wed May 16, 2007 1:12 pm
by Rings
For testing some hard&software problems,
these small util comes very handy.
You can specify the memory in Mbyte,
it will be continously written and
randomly Read.

The Code is too easy, that i post only the sourcecode here:
Should be Compatible with all PB plattform Versions (Win,Lin and OSX)
but only tested with the Windows one.
Could someone test on other plattforms ?

Code: Select all


;Mem-Stress Test, By Siegfried Rings
;
Global Abort
Procedure Stress(MB)
SizeInBytes=MB * 1024 *1024
If SizeInBytes>0
 mem=AllocateMemory(SizeInBytes)
 *pByte.byte
 If mem
 
  PrintN("MemoryblockSize="+Str(SizeInBytes)+" bytes")
  Repeat  
   c+1
   If c>(1024*100):C=0:EndIf
   ConsoleLocate(10, 6) :   PrintN("Count:" +Str(c))
   ConsoleLocate(20, 10):   PrintN("Key To abort") 
   
   For I=0 To SizeInBytes -1
    *pByte= Mem + I
    wert=Random(255)
    *pByte\b=wert
    If abort=1
     Break
    EndIf
    wert=PeekB(mem + (Random(Sizeinbytes-1)) )
    p+1
    If P>(1024*1024 )
     t+1
     P=0
     ConsoleLocate(10, 10)
     Select t
      Case 1
       PrintN("|")   
      Case 2 
       PrintN("/")   
      Case 3
       PrintN("-")   
      Case 4
       PrintN("\")   
      Case 5
       PrintN("|")   
      Case 6
       PrintN("/")
      Case 7
       PrintN("-")
      Case 8
       PrintN("\")
       t=0   
     EndSelect 
    EndIf
   
   Next i
  Until Abort=1

 Else
  PrintN("Cannot alloc " + Str(MB) +  " mb memory")
 EndIf
 PrintN("end of stress-thread")
EndIf
EndProcedure

OpenConsole()
EnableGraphicalConsole(1)
swert.s=ProgramParameter(0)
If swert=""
 PrintN("Memstress.exe SizeInMByte" )
Else
  sizeinMB=Val(swert )
  If sizeinmb>2046 
   sizeinmb=2046
  EndIf 
  ClearConsole() 
  PrintN("Memstress V1.0  by S.Rings " )
  CreateThread(@Stress(),sizeinMB)
  Delay(1000)
  Repeat
    If Inkey()<>""
     PrintN("Aborting..")
     Abort=1
    EndIf  
    Delay(1)
  Until Abort=1
EndIf
CloseConsole()
  
ok, for all gurus, yes you can start Office twice,
should be the same effect :wink:

Posted: Wed May 16, 2007 1:26 pm
by dell_jockey
Moin Rings,

verifying a random byte value that you previously poked into a memory location doesn't guarantee that you'll find individual bit errors, as it could be that one or more bits aren't changed in the process.

To find bit errors, you have to poke a location twice, using two different values that ensure that each individual bit indeed gets flipped.

Example: if you'd poke 0x55 and verify it, and then 0xAA en verify it, you'd have flipped all bits at least once, meaning that you have verified each individual bit of that memory location.

just my 2 €cents...

Posted: Wed May 16, 2007 1:36 pm
by Rings
thx for your reply.
Yes, this code did not test the memory on errors, it just
stress Windows and its memory-managment.
(and how other programms work with low memory)

anyway, nice idea to build in some
mem-compare function

Re: Memory Stress Testing

Posted: Wed May 16, 2007 3:40 pm
by dell_jockey
Rings wrote:For testing some hard & software problems,
since you also mentioned hardware, I assumed that you actually wanted to test hardware as well... :)