-2

I have a leakege here but couldnt find the problem;

@property (nonatomic,retain) NSMutableData *responseXMLData;
@property (nonatomic,copy) NSMutableData *lastLoadedResponseXMLData;

enter image description here

-(void)dealloc {
    [doc release];
    doc=nil;
    [xmlBodyTemp release];
    [responseXMLData release] ;
    responseXMLData=nil;
    [lastLoadedResponseXMLData release];
    lastLoadedResponseXMLData=nil;
    [xmlBody release];
    [super dealloc];
}
Spring
  • 11,333
  • 29
  • 116
  • 185

1 Answers1

5

Without seeing your dealloc method, we cannot be sure you are correctly releasing the values of these properties.

But in the posted code, I do see one major problem. But it's not where you think.

self.lastLoadedResponseXMLData = docTempData;

This line, although flagged by XCode, is fine (assuming you release the value correctly in dealloc).

self.responseXMLData = [self.lastLoadedResponseXMLData copy];

This line, however, is not fine. It makes a copy of whatever value is in self.lastLoadedResponseXMLData but you never release the reference due to the copy. self.responseXMLData, since it is declared "retain", adds its own reference to the object, and (assuming you release the value correctly in dealloc) this reference is the one cleaned up.

If you don't really need to care whether the object is the same or is a copy, just forgo the copy. Otherwise, autorelease it:

self.responseXMLData = [[self.lastLoadedResponseXMLData copy] autorelease];
Anomie
  • 92,546
  • 13
  • 126
  • 145
  • i updated the code, IF lastLoadedResponseXMLData was not declared as "copy" in the properties. your suggestions are still same? – Spring Aug 10 '11 at 17:45
  • could you also look at tnx http://stackoverflow.com/questions/7007767/iphone-sdk-xml-mystery-after-adding-child-nodeforxpath-returns-nothing-found-a – Spring Aug 10 '11 at 18:45
  • 1
    @XDeveloper: If lastLoadedResponseXMLData were declared "retain" instead of "copy", the situation remains the same. If it were declared "assign" things would change. – Anomie Aug 10 '11 at 19:57