Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: How do I "check before making a memory request"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I "check before making a memory request"?



On 11/29/05 4:28 PM, Scott Fraser didst favor us with:

> In the header "MacMemory.h", and in the documentation for MemError, it
> says in part:
>
> "Instead of relying on MemError(), check before making a memory request
> that there is enough memory both to fulfill the request and to support
> essential operations."
>
> My old app caches LOTS of data to improve performance, several
> gigabytes worth at a time.

First, Apple discourage caching a lot of data. I don't know the nature of
the data you're caching, but the problem with caching like this is that once
your cached data is swapped out to disk, it's going to hurt performance
instead of help it, and if you're caching this much it's invariably going to
get swapped out to disk. So you want to be sure you're only caching data if
it takes a long time to reproduce it. Nothing slows down my Mac like VM
thrashing.

> It is quite likely to (and does) run out of
> VM, let alone real memory.  However, it's very easy for me to release
> these caches if I know to do so.  What is the recommended way to check
> that there is "enough" memory left?  The only obvious (or documented)
> way of checking memory is to try to allocate some, which gets expensive
> if I have to allocate memory twice for each block of interest.  Then
> there is the old tried and true method of hanging on to a really large
> block, and freeing that before walking my cache, so I don't fail while
> doing even that.

There are some UNIX memory calls that other can tell you, or you can search
the man pages. Nothing in the Mac Memory Manager is particularly useful for
this as last time I hear things like MaxBlock just return a constant.

Larry

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How do I "check before making a memory request"? (From: Scott Fraser <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.