Re: Simple memory problem
Re: Simple memory problem
- Subject: Re: Simple memory problem
- From: Graham Cox <email@hidden>
- Date: Fri, 6 Feb 2009 10:51:23 +1100
On 6 Feb 2009, at 10:39 am, harry greenmonster wrote:
a pointer address when replaced by another address free's up the old
memory location it once pointed to, no?
No.
It just means you orphaned the object - the memory it occupies is
still err, occupied. However, in this case it's OK to do that in
theory because the string returned by -stringByReplacingCharacters...
is autoreleased, meaning that at some point the autorelease pool will
be drained, cleaning it up. But for strings 5Mb long, you have a
problem.
The question is, at what point? Certainly not within this while loop,
and that's why your footprint is growing.
So, try this:
while( ... )
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];
// ...do your thing...
[pool drain];
}
hth,
--Graham
_______________________________________________
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