Memory Size

Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Memory Size

Post 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...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Memory Size

Post 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)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Quick and useful answer, what can I say ?

THANKS A LOT !
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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"
--Kale

Image
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post 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
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

PB's answer is more shorter, and do exactly what I want, so that's ok :)
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Ah i see, tut tut, i didn't read the topic question clearly enough!
Image
--Kale

Image
Post Reply