Article # 158, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
How to determine available memory for an application
There are several ways your application can reserve or check for the largest available block size. First and foremost, you can use GeodeRequestSpace(). This will check to see if the desired space is available. If it is, it reserves the space and returns a "reservation" handle. Then allocate and use the memory you need. When done, free the memory and call GeodeReturnSpace() to free the reservation. To simply poll the system, you can use SysGetInfo(SGIT_LARGEST_FREE_BLOCK). This returns a dword that contains the size of the largest available memory block (the size is in paragraphs (1 paragraph = 16 bytes)). Another thing you can do to check mem size is to do a MemAlloc with the desired size. If it returns null handle, then you know that there wasn't enough space. One benefit of this option over the SysGetInfo option is that, if the largest free block isn't big enough, MemAlloc will compress the memory in an attempt to create a memory block that is large enough.