PDA

View Full Version : Running MEMORY and MEMORY2 example scripts under WINDOWS 7 (64bit)



GSAC3
19-01-2010, 15:55
Eros:

I frequently use the API sample scripts MEMORY and MEMORY2 to monitor memory usage, and I just discovered when I run them on a WINDOWS 7 (64bit) system they are not reporting the correct total installed memory values. The system I noticed this on has 8GB of installed memory, however MEMORY and MEMORY2 report only 4GB of installed memory.

Any idea what might be causing this difference?

Don

ErosOlmi
19-01-2010, 16:31
Well, it is simply related to the fact that 32bit numbers (LONG and/or DWORD) have a range of:
0 to 4294967295 for DWORD
-2147483648 to 2147483647 for LONG
http://www.thinbasic.com/public/products/thinBasic/help/html/numericvariables.htm
thinBasic is still a 32bit application.
We hope Power Basic will release soon a 64 bit version of their compiler so we will be able (hopefully) to release a 64 bit version of thinBasic.

One of the advantages of 64bits OS is the amount of total memory they can address: http://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx

ErosOlmi
19-01-2010, 16:45
I just checked and maybe we can use GlobalMemoryStatusEX API function:
http://msdn.microsoft.com/en-us/library/aa366589(VS.85).aspx

ErosOlmi
19-01-2010, 16:52
See if this piece of code works correctly:


'---Basic info about memory occupation

Type MEMORYSTATUSEX
dwLength As DWord
dwMemoryLoad As DWord
ullTotalPhys As Quad
ullAvailPhys As Quad
ullTotalPageFile As Quad
ullAvailPageFile As Quad
ullTotalVirtual As Quad
ullAvailVirtual As Quad
ullAvailExtendedVirtual As Quad
End Type

Declare Function GlobalMemoryStatusEx Lib "KERNEL32.DLL" Alias "GlobalMemoryStatusEx" (ByRef lpBuffer As MEMORYSTATUSEX) As Long

Dim lpBuffer As MEMORYSTATUSEX

'---Important: set UDT len
lpBuffer.dwLength = SizeOf(lpBuffer)

GlobalMemoryStatusEx (lpBuffer)

msgBox 0, "Physical memory:"+ $CRLF + _
"Available" + $TAB + Format$(lpBuffer.ullAvailPhys/1024/1024, "0")+" MB"+ $CRLF + _
"Installed" + $TAB + Format$(lpBuffer.ullTotalPhys/1024/1024, "0")+" MB"+ $CRLF + _
$CRLF + _
""

GSAC3
19-01-2010, 17:24
Eros:
:occasion:SUCCESS!!

Works like a dream.

Thanks

Don