Results 1 to 9 of 9

Thread: Max CPU & Memory

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Question

    I need a quick little app to max out my cpu and memory for short periods of time (1-5 minutes).

    I would like to schedule this to run several times a day on an idle box to test out a possible hardware problem.

    What can I do to consume all availale memory and CPU cycles without crashing the machine?

    Thanks!
    Kevin

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Private Type MEMORYSTATUS
            dwLength As Long
            dwMemoryLoad As Long
            dwTotalPhys As Long
            dwAvailPhys As Long
            dwTotalPageFile As Long
            dwAvailPageFile As Long
            dwTotalVirtual As Long
            dwAvailVirtual As Long
    End Type
    Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
    Declare Function GetTickCount Lib "kernel32" () As Long
    
    Sub MAXout(Dealy As Long)
        Dim t As Long, temp As MEMORYSTATUS, buffer() As Byte, freemem As Long
        
        t = GetTickCount
        Do Until GetTickCount > t + Dealy
            GlobalMemoryStatus temp
            freemem = temp.dwAvailPhys
            If freemem Then
                ReDim buffer(UBound(buffer) + freemem)
            End If
        Loop
        
    End Sub
    Well here's some code i just made for you, haven't tested but should max out both cpu usage and memory + will refill the memory if it's freed from another app. I'm not sure how the consequences will be if your system starts to free memory and swap stuff, it may be catastrofal, so be cautious and start with small amount of time, specify it in dealy as milliseconds. Also if this is a problem, have a small amount of memory free all the time, by changing this line:
    ReDim buffer(UBound(buffer) + freemem)
    to for instance:
    ReDim buffer(UBound(buffer) + freemem - 32768)

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Hard Disk

    What would be the best way to create some hard disk activity? Should I just do random reads & writes?
    Kevin

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No don't do any random stuff, Create a temporary file of say 1M and read the contents into a byte array, then put it back, over and over again, well not hard at all.
    Code:
    Dim Buffer() as byte
    Open "C:\Temp" For Binary As #1
       Redim Buffer(1048575)
       Do
           Put#1,,Buffer
           Get#1,,Buffer
       Loop While (Youdecidetoquit
    Close #1
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Cool Thank You!

    Thank you kindly for your help!!! Not much left for me to do!
    Kevin

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Question Problem with Max CPU

    I am getting a Subscript out of Range for the first snippet of code at:
    ReDim buffer(UBound(buffer) + freemem)

    Any ideas?

    Thanks!
    Kevin

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    place this line
    ReDim buffer(0)
    before
    t = GetTickCount

    Sorry about the bug You can't always be perfect
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80
    Ran perfectly for about 45 seconds. Now it throws an "Out of Memory Error."

    In Task manager, the CPU maxed out at 100%. The memory never got above 50% (I currently have 512MB). Since the first error, it now throws it immediately on the following line:
    ReDim buffer(UBound(buffer) + freemem - 32768)

    Thanks for your QUICK replies!!!!

    Any ideas?


    Kevin

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    damn, 512M!!! that's a bit too much, you could try to fill up empty space in different arrays.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width