Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining reasonable memory use



On Jan 31, 2005, at 4:28 PM, Mike Kluev wrote:

Let's disagree. Realistically I have to admit, that no matter how
much more I like my proposal than the current implementation, the
behavior of malloc is unlikely to change.

In a perfect world I might agree, but the system just isn't as simple as you make it out to be. Here's an example.

Each GUI process on your system right now is consuming a minimum of 200MB of virtual memory space. Some are significantly higher. You can verify this in Activity Viewer.

Their real memory space is much smaller; it looks like a regular Carbon or Cocoa app that's not doing much takes about 4-8MB of real space. Some take less, some take more, of course, but the point is that they're almost always much smaller than 200MB :)

Why is the VM size so much bigger than the actual size? That 200MB per process is because the system is sharing one copy of the common code/data with each app. Each app thinks it has its own copy of the code and data used by Carbon, Cocoa, HIViews, etc., but in reality the VM system is mirroring these pages to each process.

However, at any instant, any of these apps could ask the VM system to turn off the memory protection on this 200MB block of memory and start scribbling on top of it. Do you let one rogue app write over the shared copy of Carbon.framework that every other app is using? Of course not; the VM system at this point uses copy-on-write to spawn in a local copy of the data so that the process has its own copy of the data to trash. Making this local copy, of course, takes resources.

What do you do if the system is out of resources at that point? You're still in an "overcommitted" situation, even though there was no malloc called.

The only alternative to the current situation is to run pessimistically, and assume that each app could theoretically use up as much in the way of physical resources as it is using in virtual resources. This means that, while the current system uses up 10MB of swap for a typical process, the proposed system would be reserving 200+MB of swap. You would find yourself "running out of swap" in situations that were gigabytes away from actually being out of resources.

That's why I think the current approach has merit.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Determining reasonable memory use (From: Mike Kluev <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.