Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Virtual memory is virtual. There is absolutely no relationship whatsoever between virtual memory and actual memory used.

There is no reason to worry or even care about how much virtual memory an application shows in activity monitor. It means absolutely nothing useful to an end user whatsoever. It is specious at best to say that it is useful even to an application developer.

The number doesn't represent anything real. It is virtual.

Most people can stop reading here, but for anyone interested, let me try to explain virtual memory in layman's terms.

Let's say application A starts up and requests 10k of memory from the OS. The OS gets the request, but is smart enough to realize that the application is probably going to need more than 10k so it allocates 1 meg but only gives 10k to the application. Now when a second request for 10k comes in the OS has less work to do. It's faster to allocate a larger block and "segment" it out than to allocate many smaller blocks one at a time. If application A requests 50 more 10k blocks of memory in a second, the OS will adjust accordingly to try to predict ahead of what the application needs.

Now, application B is also running, lets say it's a web browser. Let's say the user went to a web page with a bunch of large rez images and a flash application that added up are around 10 meg. Lets say this page has been open in the browser for at least 10 minutes.

The OS is constantly monitoring memory usage and adjusting for the best performance overall. So, when it see's that application B has a bunch of memory allocated but it hasn't used it in awhile (use means read or write to it), it decides to swap the memory to disk. So it writes it to disk and releases the RAM back for other applications to use. But application B doesn't have any idea this happened. Memory is memory to the application. It doesn't need to worry about it. The OS takes care of it.

Think of the OS memory manager like a valet. When the valet takes your car, it doesn't matter where it's parked so long as you get it back when you need it.

So, the OS is constantly tweaking and adjusting memory for all the applications that are running. It tries to think ahead and adjust so that all applications perform not only quickly, but efficiently as well. If efficiency were left to the application, a sloppily written program could ruin it for all the other applications, so the OS takes care of it and does it's best to make everyone happy, and generally speaking, does a good job of it.


So then the question arises, "If the virtual memory numbers are meaningless, why are they available at all". Excellent question. Look at it this way, if you were the developer of the activity monitor, wouldn't you want to show memory usage for an application? Of course. Unfortunately, the OS cannot provide you with the actual memory usage of the applications without spending a huge amount of time calculating it. Memory management is occurring constantly and it must be extremely fast. The algorithms that determine how memory is dealt with simply do not have time to keep "user friendly" accounting. All that matters to it is giving access to the memory to the applications that need it as quickly as possible, while maintaining ultimate efficiency of resources. So, the kernel developers that deal with memory management exposed the only numbers they had readily at hand, which is virtual memory. Which, in reality, are only meaningful to the memory manager, and almost completely useless to anyone else, but at least they can display something on the activity monitor.

That is a very simplistic description, but it's the best I can do in less than 4 hours of writing. ;)
 
Virtual memory is virtual. There is absolutely no relationship whatsoever between virtual memory and actual memory used.

(+ alot more writing)

ok, so calculating the VM is hard for single applications. we are not asking that, what about measuring the whole VM size??? wouldnt that be a lot easier to specify?

also, from your writing it is my understanding that the allocations for specific programs can be taken up by other programs if it is needed? sooo VM allocations are not reserved for only one program, but are reserved for it and will gain access to it if needed?

p.s. excellent description :)
 
The virtual memory size doesn't matter. If I said I had a virtual million dollars would that buy me a Ferrari?

It's just a number. It can't be compared meaningfully with anything else. It will be different depending on RAM available, disk space available, number of applications that are running, even the order in which they were started up, or the order in which you push the buttons.

It's meaningless as a metric for any purpose.
 
The virtual memory size doesn't matter. If I said I had a virtual million dollars would that buy me a Ferrari?

It's just a number. It can't be compared meaningfully with anything else. It will be different depending on RAM available, disk space available, number of applications that are running, even the order in which they were started up, or the order in which you push the buttons.

It's meaningless as a metric for any purpose.

ok yea i can understand that. man i need to hurry up and get to uni to start getting into this stuff. its awsome!!!!
(wanna teach me :p) jks
 
The bottom line is that neither the OS nor the application "care" how much actual memory they are using. So they don't spend resources tracking it.
 
Okay, so it's a bug in Activity Monitor. Add another column (any one will do) and the Virtual Memory goes back to being a more realistic figure (for me at least).

Neither for me. Doesn't make pretty much sense either..

Thanks for your time explaining this, saltyzoo :D
 
Haha, I used CPU time ^^

Yea, Private Memory works

I chose CPU time as well, not at my mac to try private memory but its weird that quite a few of us all choose an option that is not near the top of the list.
 
You do realize that you aren't actually changing anything regarding the operation of your computer right? You're just forcing the monitor to allocate more memory which forces the memory manager to swap stuff to disk, etc, which might change the virtual numbers a bit, but it's not really doing anything constructive.
 
Okay, so it's a bug in Activity Monitor. Add another column (any one will do) and the Virtual Memory goes back to being a more realistic figure (for me at least).
That works and using 'top' in Terminal confirms the new numbers, not the insanely large ones... :)

Oh, and I had CPU time open already, so I tries # Ports first and Private Memory second... both of those worked... ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.