Separate names with a comma.
Discussion in 'Mac Programming' started by john903, Aug 31, 2009.
How do you get the available RAM remaining in a carbon app?
The definition of "available ram" is not at all clear on a modern system. Would the contents of purgeable memory count as "available"? It's in use, but will be cleared as soon as there's any memory pressure. What about mmap()'d files?
Activity Monitor lists "Free System Memory". This is the value I want to get in my app.
What do you intend to do with this value once you have it? Be specific.
I would grab the source for the 'top' command and see how it gets its information.
What does that matter? I just want to get the value!
What do you mean by the top command?
All I want is some magical function like GetFreeMemoryInMegabytes.
I found two articles for finding available memory...on the iPhone. I haven't looked at them, but due to the similarities of the platforms, I'm sure you could probably modify them a bit, or even just use them outright.
Hope that helps.
top is a unix utility that (among other things) lists free ram; like most of the unix layer of OSX, it's open source. Therefore, you can read its code to find out how to do it.
It matters because the people that you are depending on to be smarter than you (hence you asking them questions), are smarter than you and know that this value is relatively meaningless on MacOS X (at least the non-iPhone version).
In general when you are looking for help you should start out explaining what you are trying to do (broad strokes) then describe your specific question. More often than not the reason you can't seem to do what you think you need to do is because you don't understand what is going on. Thus you need to accept that other people need more information than you might think.
Cinder6: Thank you!!! Works perfect and was just what I was looking for.
larkost: I didn't mean to sound rude but it's for a complicated project so it would be to hard to explain.
Thanks for the help!