• 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: Memory Management for XML Parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management for XML Parsing


  • Subject: Re: Memory Management for XML Parsing
  • From: Jens Alfke <email@hidden>
  • Date: Sun, 12 Jun 2011 16:57:31 -0700

On Jun 12, 2011, at 2:44 AM, Bing Li wrote:

> The NSArray, nodes, is created by xmlDoc. Since the method is not the owner,
> nodes should be released here.

No, you don’t need to release ‘nodes' since you didn’t allocate or copy it.

> When a large number of XML is received, the
> receiver's memory is increased slowly.

Are you calling that method as part of a loop? If so, try allocating an autorelease pool at the top of the loop and draining it at the end. Basically, autoreleased objects don’t go away till the topmost autorelease pool drains, and if you’re doing a whole lot of stuff before returning to the event loop, you need to set up your own autorelease pool or everything will pile up till you finally finish.

In general it looks something like:

	while (…) {
		NSAutoreleasePool* pool = [NSAutoreleasePool new];
		… do stuff …
		[pool drain];
	}

‘pool’ will collect all the references that get autoreleased during ‘do stuff’, and then release them when it’s drained.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Memory Management for XML Parsing (From: Bing Li <email@hidden>)

  • Prev by Date: Re: Parent-child Design Pattern
  • Next by Date: Is it possible to create a Finder-like icon in Dock?
  • Previous by thread: Memory Management for XML Parsing
  • Next by thread: Memory Management for an Array
  • Index(es):
    • Date
    • Thread