Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Diatribe

macrumors 601
Original poster
Jan 8, 2004
4,258
46
Back in the motherland
My Mac is using almost 13GB in virtual memory, is this normal? With 2GB RAM installed I would think this thing could work with a third of that.
Just seems really odd to me.

How much does your system use?
 

Attachments

  • Picture 3.png
    Picture 3.png
    106.5 KB · Views: 465

xUKHCx

Administrator emeritus
Jan 15, 2006
12,583
9
The Kop
My VM is currently at 21.56 GB and i also have 2 GB RAM. So i'd say yours was normal.
Picture 1.png
 

DoFoT9

macrumors P6
Jun 11, 2007
17,586
99
London, United Kingdom
yea i currently have 18.94gb VM with only 7 apps open.

i am unsure why the VM sizes for each widget/application is so large. its wierd though why it would be that large for such a simple file.
 

jbstew32

macrumors regular
Jan 15, 2007
146
1
yeah I'd really like to know the answer to that as well. that's unbelievable. There's no way that these processes could actually require that much VM.

I've noticed that things seem to be automatically allotted about 350MB of VM on my machine. Maybe there's some kind of built in formula that takes into account your amount of RAM and free HD space to allot a maximum VM space for each process...idk that's all I can come up with. There's no way newly created Terminal process needs to page out 350MB.
 

Mumford

macrumors regular
Oct 8, 2006
181
3
Altadena, CA
This isn't anything to worry about. The memory allocation isn't real. There's no 300+MB void of memory (real or swap) on your comp that is causing any kind of problems.

Based on what I'm seeing from the output of top on my Mac, the widgets all seem to be using roughly the same amount of virtual memory. One 'DashboardClient' process is running per widget. It is requesting 300MB of memory when it starts, but doesn't actually use that entire 300MB. It turns out it only uses between 5-20MB (on my system anyway) per widget. I get that 5-20MB number from the RPRVT (Resident PRiVaTe memory) field in top, or the "real memory" field in Activity Monitor.

Mac OS X does "sparse" memory allocation (similar to sparse files) where a process can request a large amount of memory. The OS will respond to the process that this is done. The OS has only done this "virtually"... that is the OS has set up all the pointers for this memory, but it hasn't actually allocated this memory, either in RAM or in swap. The OS will only allocate the real memory blocks when the process tries to write to the memory locations, and even then it will only allocate 1 page (4096 bytes) at a time.

In a nutshell if I write a program that requests 20GB of memory but only uses 1MB of memory, then that 1MB is all that will ever be really allocated, even though the program is told by the OS that all 20GB was allocated.

Use vm_stat (from the terminal) to see some more realistic virtual memory numbers. The important field is 'pages allocated'.
 
  • Like
Reactions: johnalan

jbstew32

macrumors regular
Jan 15, 2007
146
1
This isn't anything to worry about. The memory allocation isn't real. There's no 300+MB void of memory (real or swap) on your comp that is causing any kind of problems.

Based on what I'm seeing from the output of top on my Mac, the widgets all seem to be using roughly the same amount of virtual memory. One 'DashboardClient' process is running per widget. It is requesting 300MB of memory when it starts, but doesn't actually use that entire 300MB. It turns out it only uses between 5-20MB (on my system anyway) per widget. I get that 5-20MB number from the RPRVT (Resident PRiVaTe memory) field in top, or the "real memory" field in Activity Monitor.

Mac OS X does "sparse" memory allocation (similar to sparse files) where a process can request a large amount of memory. The OS will respond to the process that this is done. The OS has only done this "virtually"... that is the OS has set up all the pointers for this memory, but it hasn't actually allocated this memory, either in RAM or in swap. The OS will only allocate the real memory blocks when the process tries to write to the memory locations, and even then it will only allocate 1 page (4096 bytes) at a time.

In a nutshell if I write a program that requests 20GB of memory but only uses 1MB of memory, then that 1MB is all that will ever be really allocated, even though the program is told by the OS that all 20GB was allocated.

Use vm_stat (from the terminal) to see some more realistic virtual memory numbers. The important field is 'pages allocated'.

now that sounds like a very good (and correct) answer to the question. I'm really glad you responded. I was thinking along the same lines.

why wouldn't they make the Activity Monitor application reflect the actual amount of memory being used? It seems like that would be much more helpful.

Also, let's say an application is allotted 500MB of VM, and that this application has a bug in it that causes all of it's VM potential to actually be used. What happens when it comes time for it to write it's 501st MB to the disk? does it just kill the program or allot more VM?

The answer to this doesn't really matter to me. I'm just curious I guess.
 

Pigumon

macrumors 6502
Aug 4, 2004
441
1
Wow thanks for that answer!!!

I just got a mini with 3 gb of ram, and yeah i saw that scary 25gb VM thing... :eek:
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
Wow, that's a lot. I still kinda think this is excessive. What does a widget need 600MB in VM for?

It doesn't need it. Virtual memory that is not actually used costs nothing. It's like if your bank agrees to give you $100,000 overdraft. You don't pay for it. It costs nothing. Now if you actually overdraw your account, then you pay. And if all those applications that requested 12GB of virtually memory actually started using it, all at the same time, then your Mac would be in trouble.

Also, a lot of this virtual memory is for code on the harddisk. If a program uses anything lets say from the Cocoa framework, then the whole of Cocoa is counted in the virtual memory of that application, even though only a tiny fraction may ever be used. Now if you have twenty applications doing the same thing, the whole of Cocoa is counted twenty times in virtual memory, but even if they all used everything, only one copy would be in memory. So if Cocoa was say 200MB, twenty apps would be shown as 20x200MB = 4GB virtual memory, but only 200MB of RAM would actually be used.
 
  • Like
Reactions: chabig

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
In a nutshell if I write a program that requests 20GB of memory but only uses 1MB of memory, then that 1MB is all that will ever be really allocated, even though the program is told by the OS that all 20GB was allocated.

I think the problem is that MacOS X just displays enough information to scare people, when there isn't any reason to be scared. Same with the inactive vs. free memory (I bought 2GB of RAM and only 5MB is free. What is wrong? Nothing! ). I think it would be a good idea for Apple to show things in a way that is more useful for everybody, especially for people who are not computer wizards.
 

DoFoT9

macrumors P6
Jun 11, 2007
17,586
99
London, United Kingdom
I think the problem is that MacOS X just displays enough information to scare people, when there isn't any reason to be scared. Same with the inactive vs. free memory (I bought 2GB of RAM and only 5MB is free. What is wrong? Nothing! ). I think it would be a good idea for Apple to show things in a way that is more useful for everybody, especially for people who are not computer wizards.

you would have a lot of "inactive" memory wouldnt you? because osx still keeps previous RAM contents from files in the RAM once the program/task is closed. but technically it is free.

in regards to gnasher729 your saying that it is a kind of safe-guard?? so that just incase if the program needs that amount of memory allocated, it can get it (if it is avaliable). i think that is a fairly good way of programming. it has just confused myself and some others.

DoFoT9
 

Genghis Khan

macrumors 65816
Jun 3, 2007
1,202
0
Melbourne, Australia
hmmm...my VM's are at 7Gb and 11Gb atm

i've also noticed both macs have been slower recently (maybe because HDD's are nearly full)...would wiping the hard drive and reinstaling help?
 

DoFoT9

macrumors P6
Jun 11, 2007
17,586
99
London, United Kingdom
hmmm...my VM's are at 7Gb and 11Gb atm

i've also noticed both macs have been slower recently (maybe because HDD's are nearly full)...would wiping the hard drive and reinstaling help?

sure it could help.

i would first:
•repair disk permissions
•delete unnessesary files
•log out and log back in
Or
•restart the computer
•get a program like disk warrior if you really want to
•upgrade ram.

its the simple things that make it run faster. :D
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,583
9
The Kop
hmmm...my VM's are at 7Gb and 11Gb atm

i've also noticed both macs have been slower recently (maybe because HDD's are nearly full)...would wiping the hard drive and reinstaling help?

how much space do you have left on them. The rule of thumb is that you should have 10% free, and less than this you'd be experiencing slowdowns etc.

To see what is taking up your space have a look at DiskInventory X
 

Genghis Khan

macrumors 65816
Jun 3, 2007
1,202
0
Melbourne, Australia
DoFoT9 said:
i would first:
•repair disk permissions - how?
•delete unnessesary files - done...to a point...there are bound to be ones that are in odd spots
•log out and log back in - done
Or
•restart the computer - done
•get a program like disk warrior if you really want to - i may, will it be easier than reinstalling?
•upgrade ram. - i've been thinking of doing that...atm both have 1Gb, and for AU$440 (about) i can have both at 2Gb


xUKHCx said:
how much space do you have left on them. The rule of thumb is that you should have 10% free, and less than this you'd be experiencing slowdowns etc.

Desktop - 20% free
Laptop - 9% free

oh dear:eek:

thanks guys...i'll let you know how it all goes:)
 

Mumford

macrumors regular
Oct 8, 2006
181
3
Altadena, CA
why wouldn't they make the Activity Monitor application reflect the actual amount of memory being used? It seems like that would be much more helpful.

It does... the 'Real Memory' field for each process shows how much actual real memory is set aside. And the 'Used: ###' field at the bottom will show how much of your total RAM is being used.

What it doesn't show (and what you're probably really asking about) is how much swap memory is being used. I guess that's a usability decision made by Apple. Swap isn't something the average user cares about (or even really understands). Apple hides swap in other aspects by managing swap space itself, dynamically growing it as needed without user intervention. So it seems reasonable to me they decided not to make it visible here.

Also, let's say an application is allotted 500MB of VM, and that this application has a bug in it that causes all of it's VM potential to actually be used. What happens when it comes time for it to write it's 501st MB to the disk? does it just kill the program or allot more VM?

You're confusing virtual memory with swap. Virtual memory exists in RAM as well. Say your comp has 750MB free in RAM right now, and the application you mention requests and fills up 500MB. That entire 500MB will stay in RAM, there's no reason for the OS to swap it out.

Now if said application tried to write past the 500MB ("write it's 501st MB"), the kernel would send it a memory access violation signal (SIGSEGV) and the process would be killed unless it were able to trap that error. Either way, the write wouldn't succeed.

I think the real question you were asking was "say a process requested 600MB of memory, but the system only had 500MB free in RAM. What would happen when the process wrote to the first page past 500MB?" The OS would start swapping pages to disk. Note: it won't necessarily swap pages from this process. The kernel will swap pages from any process if it (the kernel) has determined said page hasn't been used in a reasonable amount of time (which can be tuned).
 

jbstew32

macrumors regular
Jan 15, 2007
146
1
It does... the 'Real Memory' field for each process shows how much actual real memory is set aside. And the 'Used: ###' field at the bottom will show how much of your total RAM is being used.

What it doesn't show (and what you're probably really asking about) is how much swap memory is being used. I guess that's a usability decision made by Apple. Swap isn't something the average user cares about (or even really understands). Apple hides swap in other aspects by managing swap space itself, dynamically growing it as needed without user intervention. So it seems reasonable to me they decided not to make it visible here.



You're confusing virtual memory with swap. Virtual memory exists in RAM as well. Say your comp has 750MB free in RAM right now, and the application you mention requests and fills up 500MB. That entire 500MB will stay in RAM, there's no reason for the OS to swap it out.

Now if said application tried to write past the 500MB ("write it's 501st MB"), the kernel would send it a memory access violation signal (SIGSEGV) and the process would be killed unless it were able to trap that error. Either way, the write wouldn't succeed.

I think the real question you were asking was "say a process requested 600MB of memory, but the system only had 500MB free in RAM. What would happen when the process wrote to the first page past 500MB?" The OS would start swapping pages to disk. Note: it won't necessarily swap pages from this process. The kernel will swap pages from any process if it (the kernel) has determined said page hasn't been used in a reasonable amount of time (which can be tuned).


ahh yeah...you're absolutely right, I was confusing the different terms. It's been a long time since I had to think about that kind of stuff :)
 

DoFoT9

macrumors P6
Jun 11, 2007
17,586
99
London, United Kingdom
1.•get a program like disk warrior if you really want to - i may, will it be easier than reinstalling?
2.
•upgrade ram. - i've been thinking of doing that...atm both have 1Gb, and for AU$440 (about) i can have both at 2Gb


3.Desktop - 20% free
Laptop - 9% free

oh dear:eek:

thanks guys...i'll let you know how it all goes:)

1.disk warrior will defrag the computer. i have had my lappy for nearly a year and i only defragged it 2day and was at 13% total fragged files (which is kind of bad). a lot of people say that you do not need to defrag, i tend to agree with it on apples. windows computers need defrags alot more, i am unsure why.

but yes i think that if your harddrives are as full as yours, any kind of defrag will find an increase in speed.

2. upgrading ram will greatly help. $440?? that seems a bit expensive (i am aussie aswell). use a website such as staticice.com.au to find the cheapest prices (very handy web page)

3. now taht is bad. i tend to use the 30% mark. if its more than 30% full it is going to have trouble, and be more likely to have faults/errors. its overall up to you though how full you have the HD.

DoFoT9
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,583
9
The Kop
Having just upgraded to Leopard I was curious. Check it out, at one point i saw it at 105 GBs

Picture 2.png
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,583
9
The Kop
thats pretty crazy. how much free space u got on ur HD's????
mines sitting at 11.71gb after upgrading. seems to have reduced the VM seeing as though i used to use around 20gb.

btw i love leopard. so amazing

i have 30GBs free. This morning after a reboot it is only using 63GBs
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.