• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Simple memory problem (From: harry greenmonster <email@hidden>)

  • Prev by Date: Re: Needed : set class for Cocoa
  • Next by Date: Re: Simple memory problem
  • Previous by thread: Simple memory problem
  • Next by thread: Re: Simple memory problem
  • Index(es):
    • Date
    • Thread