Article Preview
Buy Now
| Print: | |
| PDF: |
Intel corner
Memory
Statistics on free and total memory on Windows
Issue: 3.5 (May/June 2005)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software REALbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 4,447
Starting Page Number: 42
RBD Number: 3519
Resource File(s):
3519.sit Updated: Wednesday, May 18, 2005 at 11:41 AM
3519.zip Updated: Wednesday, May 18, 2005 at 11:41 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
One piece of information REALbasic does not give you built-in is the amount of free memory you can use. This article will give you some code to get a few values about the current state of memory usage.
Query memory statistics
The call we use is the function GlobalMemoryStatus, which stores memory statistics in a memoryblock. This function does not have a return code (in C: VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer);). The function is part of Kernel32.dll, so the declare looks like this:
declare sub GlobalMemoryStatus lib "KERNEL32" (buffer as ptr).
This call is supported in Windows NT, Windows 98, and later versions of Windows. In Windows 2000 or newer you will also find a GlobalMemoryStatusEx call which returns correct values if there are more than 2 GB of RAM inside the PC. Our GlobalMemoryStatus call will report no more than 2 GB of RAM, but as REALbasic applications are 32bit applications they can only address 2 GB of RAM; the limit should not be a problem. (Address space is 4 GB per process, but Windows reserves 2 GB for system use.)
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










