Retrieving Memory Information...

konan

Registered
I would like my program to be able to access memory information such as available physical ram, memory load, etc. This information is only being used to inform the user when they are consuming too much RAM and their system performance will be affected.

With windows, I call the function GlobalMemoryStatus(). What is the equivalent for Mac OS X (Carbon)?

Konan
 
I discovered that I can use the command "top -l 1" in terminal to retrive this information, but I am having trouble doing this directly in my app. I tried...

InFile = popen("top -l 1", "r");
if (InFile)
bytesRead = fread(streamBuffer, sizeof(char), sizeof(streamBuffer), InFile);
pclose(Infile);

However, bytesRead is always returning 0.

Can anybody see what I am doing wrong, and, is there any other way to determine how much memory is being used (there must be)?

Konan
 
This would be great, however it has to be built into my software package. The logic will go like this...


if (ratio of (available physical ram) to (total physical ram) is too low)
Print Message ("Your system is low on RAM so this program will not perform optimally).

This should be really easy to do (with the right information). In the Windows version of my software, I simply call a GetMemoryStatus() command.

Any help would be greatly appreciated :)
Konan
 
konan said:
This would be great, however it has to be built into my software package. The logic will go like this...


if (ratio of (available physical ram) to (total physical ram) is too low)
Print Message ("Your system is low on RAM so this program will not perform optimally).

This should be really easy to do (with the right information). In the Windows version of my software, I simply call a GetMemoryStatus() command.

Any help would be greatly appreciated :)
Konan

Sorry, I read that wrong. I thought what you meant by "program" was "Finder".
 
Back
Top