13GB virtual memory?

Discussion in 'Mac Basics and Help' started by Diatribe, Oct 11, 2007.

  1. Diatribe macrumors 601

    Diatribe

    Joined:
    Jan 8, 2004
    Location:
    Back in the motherland
    #1
    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?
     

    Attached Files:

  2. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #2
    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
     
  3. Diatribe thread starter macrumors 601

    Diatribe

    Joined:
    Jan 8, 2004
    Location:
    Back in the motherland
    #3
    Wow, that's a lot. I still kinda think this is excessive. What does a widget need 600MB in VM for?
     
  4. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #4
    All my widgets are at 365 ± 10 MBs which i'd consider a lot but i don't really know how VM works
     
  5. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #5
    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.
     
  6. jbstew32 macrumors regular

    Joined:
    Jan 15, 2007
    #6
    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.
     
  7. Mumford macrumors regular

    Joined:
    Oct 8, 2006
    Location:
    Altadena, CA
    #7
    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'.
     
  8. jbstew32 macrumors regular

    Joined:
    Jan 15, 2007
    #8
    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.
     
  9. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #9
    top notch answer Mumholden.
    explained everything perfectly :) thanking you sooo much
     
  10. Pigumon macrumors 6502

    Pigumon

    Joined:
    Aug 4, 2004
    #10
    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:
     
  11. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #11
    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.
     
  12. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #12
    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.
     
  13. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #13
    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
     
  14. Genghis Khan macrumors 65816

    Genghis Khan

    Joined:
    Jun 3, 2007
    Location:
    Melbourne, Australia
    #14
    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?
     
  15. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #15
    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
     
  16. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #16
    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
     
  17. Genghis Khan macrumors 65816

    Genghis Khan

    Joined:
    Jun 3, 2007
    Location:
    Melbourne, Australia
    #17
    •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


    Desktop - 20% free
    Laptop - 9% free

    oh dear:eek:

    thanks guys...i'll let you know how it all goes:)
     
  18. FJ218700 macrumors 68000

    FJ218700

    Joined:
    Mar 8, 2007
    Location:
    Blue Dot, Red State
    #18
    disk utility (in Applications --> utilities)
     
  19. Genghis Khan macrumors 65816

    Genghis Khan

    Joined:
    Jun 3, 2007
    Location:
    Melbourne, Australia
    #19
    ah thanks:)

    really must use that utilities folder more:p
     
  20. Mumford macrumors regular

    Joined:
    Oct 8, 2006
    Location:
    Altadena, CA
    #20
    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).
     
  21. jbstew32 macrumors regular

    Joined:
    Jan 15, 2007
    #21

    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 :)
     
  22. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #22
    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
     
  23. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #23
    Having just upgraded to Leopard I was curious. Check it out, at one point i saw it at 105 GBs

    Picture 2.png
     
  24. DoFoT9 macrumors P6

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #24
    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
     
  25. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #25
    i have 30GBs free. This morning after a reboot it is only using 63GBs
     

Share This Page