View Full Version : get available RAM
john903
Aug 31, 2009, 09:14 PM
How do you get the available RAM remaining in a carbon app?
Catfish_Man
Sep 1, 2009, 02:54 AM
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?
john903
Sep 2, 2009, 04:01 AM
Activity Monitor lists "Free System Memory". This is the value I want to get in my app.
chown33
Sep 2, 2009, 01:25 PM
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.
Catfish_Man
Sep 2, 2009, 04:20 PM
Activity Monitor lists "Free System Memory". This is the value I want to get in my app.
I would grab the source for the 'top' command and see how it gets its information.
john903
Sep 3, 2009, 01:26 AM
What do you intend to do with this value once you have it?
What does that matter? I just want to get the value! :D
I would grab the source for the 'top' command and see how it gets its information.
What do you mean by the top command?
All I want is some magical function like GetFreeMemoryInMegabytes.
Cinder6
Sep 3, 2009, 01:47 AM
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.
http://adeem.me/blog/2009/04/01/get-the-amount-of-free-memory-available-in-iphone-application/
http://landonf.bikemonkey.org/code/iphone/Determining%5FAvailable%5FMemory.20081203.html
Hope that helps.
Catfish_Man
Sep 3, 2009, 02:12 AM
What do you mean by the top command?
All I want is some magical function like GetFreeMemoryInMegabytes.
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.
larkost
Sep 3, 2009, 08:56 PM
What does that matter? I just want to get the value! :D
All I want is some magical function like GetFreeMemoryInMegabytes.
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.
john903
Sep 4, 2009, 12:29 AM
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!
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.