|
|
Explanation
The Finder isn't actually allocating the memory, it is mapping it. There is a difference, but the end result is the same (and a bug).
When you browse a set of images, the Finder-- likely QuickTime or something related to the imaging infrastructure-- is asking the Mach memory manager to map the image data into memory. There is a difference between mapping a file into memory and allocating a hunk of memory and reading the file into that memory. Namely, when the system needs to page out a hunk of mapped memory (the image is no longer being previewed in the finder), it can simply dump the data in memory as the file already exists on disk-- there is no need to write the data out to the swapfile. Because the current generation of machines are 32 bits, a process cannot simply map every file on disk into memory. As each file is mapped, it is assigned a virtual address within the process. If the process [Finder] tries to map in more than 4GB (likely less because of a series of reserved addresses) into memory, it will exceed the 32bit address space and crash (unless it does some fairly esoteric mach level memory interrupt handling). Obviously, Finder shouldn't crash in this case. The problem is that the Finder is not releasing the mapped memory. Keep in mind that simply because a file is mapped into memory, it may not actually be occupying a physical hunk of memory. By mapping a file, the mach memory manager simply reserves a set of addresses to correspond to the contents of that file. The contents of the file are not physically read into RAM until the program tries to actually read the data. All of this (except the Finder crashing part) is the reason why you'll often see applications claiming that they are using tons of RAM listed in the VSIZE column. Just because it is listed does not mean the app has actually used that much physical memory + swap space. The mach memory manager can also preallocate memory. For example, PhotoShop could choose to "allocate" 2GB of RAM from the mach memory manager. This only means that PhotoShop has indicated to mach that it wants a 2GB address space, not 2GB of memory. As PhotoShop writes data into that 2GB of memory, the mach memory manager will take care of ensuring that the memory is backed by physical RAM and, as needed, swaps the oldest accessed pages out to disk.
Explanation
Thanks for the clear explanation, Bill. Now if we can just corral the henny-penny's of the Mac OS X world and force them to read what you've written then the number of posts claiming that the sky is falling should diminish dramatically. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|