Re: Calling allObjects memory allocation problem
Re: Calling allObjects memory allocation problem
- Subject: Re: Calling allObjects memory allocation problem
- From: "Clark S. Cox III" <email@hidden>
- Date: Sat, 22 May 2010 15:30:51 -0700
On May 21, 2010, at 8:54 AM, Keary Suska wrote:
> On May 21, 2010, at 9:18 AM, Paul Sanders wrote:
>
>>> Also be aware that just because memory is released, doesn't mean it is returned to the system (e.g. you will not
>>> see your apps memory usage go down in Activity Monitor). In fact, AFAIK, it is never returned to the system,
>>> except perhaps in low memory situations.
>>
>> I don't actually think that's true. At least, it's not what I observe. I think it's more accurate to say that you cannot predict when memory which has been allocated and then freed will be returned to the operating system, nor how much. It happens, I believe, in 4k pages, but probably not one at a time and will be heavily dependent on fragmentation of the process's heap. No doubt there is much more to know.
>>
>> I agree with the sentiment of keeping an eye on your peak memory usage. I use Instruments for this, and it found one instance where memory usage was creeping steadily up when the app was playing audio but otherwise idle.
>
> Maybe AFAIK should be "As Far As I have Observed", as although using tools like instruments I have seen constant tiny increases and decreases, I have yet to see peak memory reduce over the lifetime of an application. Fragmentation could certainly play a role--I don't know of any means to check that. If this truly is the issue most of the time, it seems to me that for most practical points and purposes that the memory won't get returned anyway, as fragmentation seems to be so common.
Allocations below a certain size (which varies based on CPU and installed RAM and other factors) are unlikely to be returned to the OS. Instead, they are re-used for future allocations of similar size. Allocations above that size are allocated directly from the OS and are returned thereto upon deallocation. Of course, all of the parameters are subject to change (and have changed over various OS releases), but the general concept holds. This is, of course, why tools such as heap are much better for inspecting your process' memory usage than tools like Activity Monitor, as they are much better informed about the specific behavior of malloc._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden