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 Sun, 30 Jan 2005 12:04:03, David Duncan <email@hidden> wrote:

> On Jan 30, 2005, at 10:16 AM, Mike Kluev wrote:
> 
>> Or carefully track memory usage and compare it to remaining space.
>> In other words, malloc should "reserve" vm space and this reservation
>> should be honored by other mallocs or file operations (!) and that
>> should be system wide. If that is true, then in the above example
>> NewHandle(.9GB) will fail and NewHandle(.4GB) will succeed.
> 
> And of course, there are disadvantages to that as well. What if .9GB is
> allocated and only .4GB of it is used (for whatever reason). And what
> if .4GB was available on disk when the handle was requested but .9GB
> becomes free later (who knows why). And of course, the ever popular App
> A requests .4GB that it will use over the course of an hour, while App
> B needs 1MB that it will need right now but will be done with in 30
> seconds. Why should App B be starved because App A preallocated?

Those are all valid examples, but the worst thing that could happen
in this "pessimistic" implementation is that the caller of malloc will
get back NULL. Something the caller should be prepared and handle anyway.
With the current "optimistic" implementation he will get back non null
but may crash on attempt to write to that memory. The former, while not
perfect is much closer to ideal than the latter, IMHO.

Mike

 _______________________________________________
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



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.