No paging, so why more RAM?

ericmurphy

Registered
I've got two Power Macs: a 500 MHz G4 with 1.25 Gig of RAM, and a dual 2 GHz G5 with an even gig of RAM. If I run the same number and type of applications and processes (e.g., mail, address book, safari, quicken, photoshop, illustrator, terminal running top, activity manager) I notice that the G4 (which actually has more RAM) seems to use significantly more physical memory than the G5 does, with about the same amount of paging in the same amount of uptime. Right now the G4 has about 70 processes running, 1.22 gig used, 36 meg free. Meanwhile, the G5 has 80 processes running, 740 meg used, 280 meg free. Is the system architecture of the G5 maybe more efficient with RAM? Both machines have a total of 1 Meg of L2 cache, so that doesn't have anything to do with it.

Anyway, the real point is, for the mix of applications I currently use, I wonder if additional RAM for the G5 would be money well-spent. I know OS X tends to grab as much memory as available, so the fact that I have more than 250 Meg free leads me to believe that until I start editing video or rendering 5-minute animations, maybe I should hold off on more RAM.

Thoughts?
 
Both machines are running basically the same group of apps, so I don't think it's a matter of which applications are running. I have the feeling that it might be a matter of different system architecture and bandwidth.

And in the final analysis, it doesn't matter. What the question really boils down to is, with 25% of physical memory unused under typical workload, will I see a performance benefit from additional RAM (e.g., 1 Gig increased to 3 Gig)?
 
i think you misundersood my question. if you are running the exact same apps on both machines but the memory usage is different i would expect that some of those apps are using more memory on one machine than the other to create that imbalance. which apps are doing this?

and no, you won't see a performance boost if you never run out of ram to begin with.
 
Hardware does not know/care, will not care, about your RAM. It's completely up to the OS (the kernel more specifically). It's not like the G5 CPU itself will say "oh I'm gonna reserve X amount of RAM for this app, and Y amount for that app." Nope, don't worry yourself over that at least.

The kernel has its own logic for figuring out what to do with RAM, think of it as artificial intelligence if you want. So on 2 identical hardware systems (for the sake of a control) you can boot it up and run the same apps in the same order do everything the same, there's no guarentee they both will use (or not use for that matter) the same amount of RAM.
 
Possibly some apps are compiled with G5 optimizations that end up using less RAM when they run on a G5. A recent version of Photoshop seems like a likely candiate. Check the activity monitor for the VM size of the apps you're running.
 
actually won't it be the same on setups where you don't approach the end of available memory? that is, so long as there no threat of running out of memory a system X will give the same maximum amount of memory requested to safari as will system Y in the same circumstances.

i was under the impression that things only got interesting if they had to.
 
I think we first need to address the misunderstanding about RAM under OS X in the first place. Just because "top" or the system reports that there's "XXX amount of RAM free" doesn't mean that's all the unused RAM that's available.

It's going to be a combination of "free" memory and "inactive" RAM that gives an indicator as to how much RAM is available for the systems to use -- and even these numbers will change constantly.
 
the G4 uses more ram because it has more ram. the end.

this is how osx works. it uses as much ram as it can. I have 1GB and often only 40 MB or less free.
 
Yes, but "free" is just the portion of RAM that doesn't have anything stored in it, and is available for the system to use immediately.

"Inactive" RAM is the portion of RAM that has something stored in it but is no longer in use or needed -- like stuff from a program you recently quit. It stays in memory for those "just in case" scenarios, like if you immediately re-launch the program you just quit -- stuff it needs is already in RAM and doesn't have to be loaded again, and the program launches faster. However, it is just as available for use by the system or another application as the "free" RAM is.

I'll have to agree with blue&white that the more RAM you have installed, the more that OS X will use -- looking at the "free" RAM does not give you an accurate representation of how much "unused" or "available" RAM you have.
 
thanks for that info..

I always thought that inactive was kinda stuck for a designated amount of time till the os figured its contents were no longer needed. the reason I think this is that everytime I check my free total in the morning its always much higher than it was before I went to bed.

seems logical to me.. am I way off?
 
blue&whiteman said:
the G4 uses more ram because it has more ram. the end.

this is how osx works. it uses as much ram as it can. I have 1GB and often only 40 MB or less free.

this is true to some extent. but if i have a gig on machine 1 and 2 gigs on machine 2 and i start up safari, they should both mark off the same amount of memory for it. at least i would think so. anyone know for sure here?
 
blue&whiteman said:
thanks for that info..

I always thought that inactive was kinda stuck for a designated amount of time till the os figured its contents were no longer needed. the reason I think this is that everytime I check my free total in the morning its always much higher than it was before I went to bed.

seems logical to me.. am I way off?

Yes and no... the inactive memory has data stored in it, but any application (including the application whose data is in the inactive memory) is free to use that memory. Over time (or after other processes have run) the OS will either use that memory for other current applications (making it from inactive to active) or it will free the contents (making it from inactive to free).

Inactive memory and free memory are basically the same thing in the sense that it's memory available for the system/applications to use. Active memory is not free for the system or a new application to use, since it's still in use by some process.
 
One important thing is that the system remembers what is on a page of inactive memory and it doe not need to reread it from the disk if it is needed. For example if you execute 'ls' from the terminal that actually loads the ls command into active memory from the disk, executes it, and terminates. Now if the memory containing the code of ls is just made inactive at the point ls terminates the next time you run ls that memory can just be reactivated and not reread from the disk. Since the disk is like a bazillion times slower than memory this is a huge win.
 
cfleck said:
this is true to some extent. but if i have a gig on machine 1 and 2 gigs on machine 2 and i start up safari, they should both mark off the same amount of memory for it. at least i would think so. anyone know for sure here?
Safari is a bad example. Take into consideration things like bookmarks, history data, whether or not it goes to a certain homepage on startup, etc. Little factors such as those might not impact memory usage very much, but if the differences are enough, then you won't see it using the same exact amount of RAM on each computer.
 
I bought a 1.5ghz G4 powerbook with 1 gig of ram and a Dual 1.8ghz G5 also with 1 gig of ram, installed Panther on both, and an identical subset of applications (so identical, I actually copied most of the applications across directly from the PB to the G5).

Point of note: I use Menu Meters to measure my memory usage.

I immediately noticed that the G5 used significantly more ram on boot-up. Fair enough I thought, it's a different architecture. But I then noticed that loading up Google in Safari would make the difference even greater. Loading other apps such as Photoshop also increased this trend. The G5 appeared to be consistently using more for the same task than the G4 would use.

At the time, I put this down to the 64-bit addressing of the processor. I figured that using 64-bit addressing was somehow causing increased memory usage. I went and purchased an additional gig of ram for the G5, and was pleased with the performance. However, I still manage to regularly push the G5 much closer to its memory limit than the G4 when performing similar tasks, such that I would desperately love to double my ram again.

I refer to the definition of 64-bit computing in Wikipedia to support this theory (http://en.wikipedia.org/wiki/64-bit) :

"The main disadvantage of 64-bit architectures is that relative to 32-bit architectures the same data occupies slightly more space in memory (due to swollen pointers and possibly other types and alignment padding). This increases the memory requirements of a given process, and can have implications for efficient processor cache utilisation. Maintaining a partial 32-bit data model is one way to handle this, and is in general reasonably effective."

When searching for other possible explanations for this, I came across this document advising developers how to optimise applications for the G5: http://developer.apple.com/technotes/tn/tn2086.html

"The G5 contains a very efficient memory prefetch engine to start gathering data from memory for the processor before it's actually needed. The G5 prefetch engine notices when an application is accessing sequential memory addresses within a cacheline (128 bytes) of each other and starts loading further sequential memory into the data cache, so it will be immediately available if and when you need it."

This feature has to be specifically taken advantage of by the developer, and this would almost certainly have been done in the case of Safari and most likely Photoshop. I illustrate this not because I believe it is the cause of this increased memory usage but to disagree with Lycanders observation that "Hardware does not know/care, will not care, about your RAM.". Yes, I agree it is the kernel that does the memory management on a software level, but it does so by taking advantage of features and pathways of the processor (including the MMU - memory management unit) and the logic board.

This article has an interesting but not particularly related theoretical discussion of some of OS X's memory management procudures - http://www.macosxhints.com/article.php?story=20010613140025184&query=memory

There also used to be a good tip on macosxhints.com (I think) for tweaking certain sysctl parameters to make os x run better on systems with larger memory, but I could not locate it for this post.

As pointed out previously by others, the amount of "free" memory does not necessarily represent the amount of "available" memory. The BSD kernel, like the linux kernel, takes memory for all sorts of tasks, from window caching to task caching etc. So you shouldn't fear just because your system appears to be out of available ram. If your system is using a lot of ram on startup, it would be wise to review things such as what Startup items are loaded by the user in the Accounts panel, and check what additional services SystemStarter might be running by looking in /Library/StartupItems. Other factors might include the number or size of fonts, wallpapers, bookmarks etc you have installed.

Incidentally if you find Safari's bookmark menu REALLY slow (and you don't prefer Camino like I do), then simply sort them so that there are as few entries or folders at the root level as you can possibly manage. You will find that hundreds of bookmarks will incur no slow-down in menu pop-up as long as you have them categorised into sub-menus with no more than 5-8 folders in the "root".
 
Well, here's the deal. My G5 has been up for about 20 days now (since the last security update that required a reboot), and with twenty-four applications up (including Photoshop, Filemaker, Illustrator, Word, and Excel), I've still got about 30 Meg free out of 1,000 Meg total (with about 12.5 Gig of swap space). Granted, there have been over a million page-outs, but I'm wondering what those memory specs would look like if I had a full (say) three gigabytes. Would I still have minimal free RAM but way fewer page-outs? That would be my guess. Performance on this machine is very satisfactory (to the point where every Windows machine I use, including a 3.0 GHz Xeon server, seems painfully slow), but it would be interesting to see how performance would improve if I tripled RAM.
 
64 bit addressing doesn't affect the G5's at the moment since Panther doesn't support 64 bit addressing. This may be an issue in Tiger.
 
Back
Top