PDA

View Full Version : Memory usage in Panther



Ignoramus
16th May 2004, 02:13 AM
Whilst I know that OS X loves ram, I am wondering such a significant amount of ram is allocated to inactive processes. I have 768MB of ram in my iBook and upon first start up I have about 600MB of ram free, with the active processes using 67MB and the inactive processes using 44MB. Obviously when i start applications the amount of free memory would decrease. However even after I close all applications, the amount of memory free is only about 130MB.

Looking in the activity monitor, it reports that 356MB of memory is allocated to inactive processes while 211MB is allocated to active processes. Can someone explain why so much ram is required by the inactive processes, wouldn't they be paged out to the hard drive? Or am I suffering from memory leakage? Also can someone please explain what the wired component is in the activity monitor. Are there any unnecessary services that are started up by default, which can be removed to free up ram?

Damian
16th May 2004, 02:00 PM
Wired = memory used by the kernel. Generally always in RAM

Shared = used by two or more processes - like icons, or inter-process communication where two progams talk to each other (such as a word processor talking to the printer service)

Active = in RAM and recently used block (system is hanging on to it because it expects re-use)

Inactive = in RAM but not recently used. Can be released at any time if space needed by other programs. Basically just sitting there until space is needed - hence it may appear to be a lot of RAM at times. Ready for use in any case. The OS doesn't waste time by proactively removing. Does it when it needs to. This being high is not a problem in itself.

Free = just that (not committed to anything)

A memory leak would show up with 'top' in a terminal window.

Try this in a terminal windows: top -o rsize

This will show memory use by process (program).

Monitor over time to see if anything is endlessly going up.

I haven't seen anything so far and I run a lot of apps.

Damian

kim jong il
18th May 2004, 08:23 AM
Firstly i see that you already have the basic answer above and to this i cannot really add much except a few links for further reading which you (and anyone else who has studied the activity monitor and has aksed themselves the same questions).

It is possible that you may have unwittingly made certain assumptions about the OS and maybe compared its memory usage and allocation to desktop machines or worse still, to OS 9. Unlike OS 9, OS X manages memory in a dynamic fashion rather than use a static allocation. Your powerbook will use much more of the physical RAM for a given set of applications than a desktop for this very simple reason: power management. It is far more energy efficient to store unused or inactive 'pages' (chunks of data = 4096 bytes) than to swap them to the hard drive and subsequently retrieve them if needed. My machine according to the activity monitor + other utilities only ever retrieves 9.9% of this data so storing this in RAM rather than the hard disk will offer two distinct benefits. a. Performance. Access from RAM is quite a bit faster than your hard disk. b. Power management. RAM uses far less power than your hard disk.

A discussion of the way OS X dynamically utilises RAM can be found here:

http://developer.apple.com/documentation/P...boutMemory.html (http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/Concepts/AboutMemory.html)

And in plainer language, a series of posts collected together, discussing the same issue can be found here:
http://www.macosxhints.com/article.php?sto...010613140025184 (http://www.macosxhints.com/article.php?story=20010613140025184)

I would thoroughly reccomend that you read at least the second of these as it is quite enlightening.

Remember, when your powerbook (or desktop) says e.g 170 MB free, do not interpret that as 170 MB left. Your OS is constantly assessing and adjusting RAM allocation to system requirements. Your powerbook for example is caching 100 MB more data in RAM than my desktop (I replicated the scenario you described on my desktop with the following results)

768 MB RAM (all applications closed down)
wired: 68 MB
active: 209 MB
inactive: 220 MB
used: 497 MB
free: 271 MB
virtual memory: 2.57 GB

This last thing may be of interest to those not wishing to do any further reading. In one article in one of the links above it suggests that as unused 'pages' are removed, system performance improves as more items that are constantly being re-used remain cached in RAM.

OS X (and I guess therefore UNIX) is really a brilliant piece of work. The more i find out about it the more i love it. Do some experiments and try to bog the machine down (I dont mean open 150 images in photoshop as this application allows you to allocate a percentage of available RAM to it exclusively). With 768 MB I have not been able to make it keel over. Start removing physical RAM and you can see a graphic demonstration of performance reduction and real changes in the way the OS is managing available resources.

One guy* comments that he thought that OS 10.(1?) was a bit slow when running in 32 MB (YES, 32!, not a typo) but improved dramatically with an extra 128 MB (total 160 MB) on an imac 233. Likewise, if you scrimp on RAM in a powerbook, not only will you lose performance but battery life will take a pounding too.

*EDIT: for a laugh here is the link to this 'review' http://www.wired.com/news/technology/0,128...n_story_related (http://www.wired.com/news/technology/0,1282,40568,00.html?tw=wn_story_related)

Basically, my, rather long winded, response means DON'T WORRY. Nothing is amiss.

cheers, kim

Ignoramus
18th May 2004, 10:58 AM
Thanks guys for clearing it up for me. While I was just wondering why this was the case even after I increased the ram. Before the upgrade, I only had about 3mb free, and yeah coming from a desktop with 1GB of ram with usually about 700MB free (it's a PC) I had never seen free memory so low

However it makes sense why the memory wouldn't be paged out to the hdd as it would affect the battery life.