• 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: NSXMLNode's `stringValue' method and memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLNode's `stringValue' method and memory leaks


  • Subject: Re: NSXMLNode's `stringValue' method and memory leaks
  • From: Damien Sorresso <email@hidden>
  • Date: Fri, 2 Dec 2005 19:02:29 -0600

On 2 Dec, 2005, at 6:47 PM, Glen Simmons wrote:
On Dec 2, 2005, at 6:36 PM, Damien Sorresso wrote:
I'm using NSXMLNode's `stringValue' method to get the raw string value of an XML node, but it seems like every time I call this method, I get

2005-12-02 18:15:20.818 XMLTest[15637] *** _NSAutoreleaseNoPool(): Object 0x307ea0 of class NSCFString autoreleased with no pool in place - just leaking

in the run log. But from what I can tell, the object it returns isn't autoreleased. The assignment statement is

curVal = [[names objectAtIndex:i] stringValue];

The `names' array contains `NSXMLNode' objects, and it is obtained from a `NSXMLNode' passed into the function. Every time the above statement is executed, the aforementioned message is printed to the console. The address of the object in the message is always the same as the address of `curVal'.

What's going on here?

You need an autorelease pool. Even though you aren't autoreleasing anything, Cocoa obviously is. *Any* interaction with Cocoa may create autoreleased objects that you don't know about. Since the main thread already has an autorelease pool in place, I'm guessing you're doing this on a secondary thread. If you check the docs, it says somewhere to always begin your threaded method with

NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

and end it with

[pool release];


Glen Simmons

That's the only explanation I could think of, but I'm not doing this in another thread. I'm only using a CLI test binary right now. I've tried adding a pool, but when I do, the program simply crashes and outputs the same messages over and over.
--

Damien Sorresso

"It is not so much that I have confidence in scientists being right, but that I have so much in nonscientists being wrong."
-Isaac Asimov, in "Asimov's Corollary".


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

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

This email sent to email@hidden
  • Follow-Ups:
    • Re: NSXMLNode's `stringValue' method and memory leaks
      • From: j o a r <email@hidden>
References: 
 >NSXMLNode's `stringValue' method and memory leaks (From: Damien Sorresso <email@hidden>)
 >Re: NSXMLNode's `stringValue' method and memory leaks (From: Glen Simmons <email@hidden>)

  • Prev by Date: saving table column width, order, and sort
  • Next by Date: Re: NSXMLNode's `stringValue' method and memory leaks
  • Previous by thread: Re: NSXMLNode's `stringValue' method and memory leaks
  • Next by thread: Re: NSXMLNode's `stringValue' method and memory leaks
  • Index(es):
    • Date
    • Thread