Page 1 of 1
Memory Size
Posted: Sun Jan 18, 2004 12:04 pm
by Polo
I'm searching a command which can get the memory size, something like :
size = MemorySize(memory_id#)
But it doesn't seems to exist in Purebasic...
Re: Memory Size
Posted: Sun Jan 18, 2004 12:15 pm
by PB
You can do it with the GlobalSize API command like this:
Code: Select all
Unknown=Random(99999)
MemID=AllocateMemory(1,Unknown,0)
Debug Unknown
Debug GlobalSize_(MemID)
Posted: Sun Jan 18, 2004 1:40 pm
by Polo
Quick and useful answer, what can I say ?
THANKS A LOT !
Posted: Sun Jan 18, 2004 2:11 pm
by Kale
or:
Code: Select all
GlobalMemoryStatus_(Memory.MEMORYSTATUS)
Debug "Memory length: " + Str(Memory\dwLength) + "bit"
Debug Str(Memory\dwMemoryLoad) + "% of memory is being used"
Debug "Total installed memory: " + Str(Memory\dwTotalPhys) + " bytes"
Debug "Available memory for use: " + Str(Memory\dwAvailPhys) + " bytes"
Debug "Total page file size: " + Str(Memory\dwTotalPageFile) + " bytes"
Debug "Page file available for use: " + Str(Memory\dwAvailPageFile) + " bytes"
Debug "Total virtual memory size: " + Str(Memory\dwTotalVirtual) + " bytes"
Debug "Virtual memory available for use: " + Str(Memory\dwAvailVirtual) + " bytes"
Posted: Sun Jan 18, 2004 4:09 pm
by tinman
Kale wrote:or:
Code: Select all
GlobalMemoryStatus_(Memory.MEMORYSTATUS)
Despite what the platform SDK says, I found that I had to manually set the length in the structure (seemed that GlobalMemoryStatus used it as a check to ensure the pointer to the structure was valid).
I'm sure my old Win32 reference manual mentioned that, but not the platform SDK.
Besides, that gets info about the system memory, not the size of the memory already allocated ;p
Posted: Sun Jan 18, 2004 4:27 pm
by Polo
PB's answer is more shorter, and do exactly what I want, so that's ok

Posted: Mon Jan 19, 2004 2:26 am
by Kale
Ah i see, tut tut, i didn't read the topic question clearly enough!
