CPU & RAM

Blitz3D Forums/Blitz3D Programming/CPU & RAM

Mr. Slat(Posted 2007) [#1]
Are there any commands to get the avaiable RAM and the CPU usage?


D4NM4N(Posted 2007) [#2]
Not built in (that i know of) but you could probably get this info from a kernel32 call or something. Check in the decls section in the codearcs


Rroff(Posted 2007) [#3]
heres how to get the memory info without decls...

memstatus = createbank(31)
mem = calldll("kernel32.dll","GlobalMemoryStatus",memstatus)
availableMemory = peekint(memstatus,12) / 1024 / 1024
Print "Available Physical Memory: "+ availableMemory + "MB"
Waitkey()
End


Rroff(Posted 2007) [#4]
peekint(memstatus,0) = info len
peekint(memstatus,4) = Memory Load (in percent)
peekint(memstatus,8) = Total Physical (you can also get this from the callDll return value (mem))
peekint(memstatus,12) = Available Physical Memory
peekint(memstatus,16) = Total Page File
peekint(memstatus,20) = Available Page File
peekint(memstatus,24) = Total Virtual
peekint(memstatus,28) = Available Virtual


Rroff(Posted 2007) [#5]
Getting CPU usage could be tricky as I am not aware of any standard API function for returning this (except by using performance monitors and not everyone has that enabled)


puki(Posted 2007) [#6]
http://www.blitzbasic.com/codearcs/codearcs.php?code=403


Rroff(Posted 2007) [#7]
Yeah but I can all but guarantee you that DLL (which probably uses the 2-3 different enum process and cumulative process useage methods to get the data) will not work on a good number of people PCs... even if you use all 5 methods including undocumented/depreciated functions in ntdll.dll you will still unfortunatly not be able to guarantee it works on all clients machines.


Mr. Slat(Posted 2007) [#8]
Thanks guys :P