Memory leak


hi all,
in app ,i parsing xml files using nsxmlparser.to connect url making use of nsurlconnection.we using synchronous connection.this return nsdata type. in performance tool checking leaks.

- (void)parsexmlfileaturl:(nsurl *)url parseerror:(nserror **)error
{


therequest=[nsurlrequest requestwithurl:url];

nserror *connectionerror= nil;
receiveddata = [nsurlconnection sendsynchronousrequest:therequest returningresponse:&response error:&connectionerror];


nslog(@"\n\n---------succeeded! received %d bytes of data",[receiveddata length]);

if([receiveddata length] != 0)
{
//catalogobj = [catalog getcatalogobject];

@try
{

parserobject = [[nsxmlparser alloc] initwithdata:receiveddata];

//receiveddata = nil;
//therequest = nil;
//response = nil;
}
@catch (nsexception *e)
{
nslog(@"error : name: %@\nreason: %@\n\n",e.name,e.reason);
}

[self.parserobject setdelegate:self];
[self.parserobject setshouldprocessnamespaces:no];
[self.parserobject setshouldreportnamespaceprefixes:no];
[self.parserobject setshouldresolveexternalentities:no];


@try
{
[self.parserobject parse];
}
@catch (nsexception * e)
{
nslog(@"error : name: %@\nreason: %@\n\n",e.name,e.reason);
}
@finally
{

nserror *parseerror = [self.parserobject parsererror];
if (parseerror)
{

nslog(@"\n------------------");
nslog(@"\nparse error occured.....\ndescription: %@\nreason: %@\nsuggestion: %@\ninfo: %@\n\n",[parseerror localizeddescription],[parseerror localizedfailurereason],[parseerror localizedrecoverysuggestion],
[[parseerror userinfo] objectforkey:nserrorfailingurlstringkey]);
nslog(@"\n------------------");
}

[parseerror release];

//[parserobject release];

}
}




}



showing leak peak.when click on there show me leaked blocks
, go
receiveddata = [nsurlconnection sendsynchronousrequest:therequest returningresponse:&response error:&connectionerror];
line of code in app.

how release memory occupied this.im releasing receiveddata in dealloc funcn,but still there leak how solve it.
 

i think maybe should releasing receiveddata after use handing parser object. or before assignment, point need release once each time method called, because you're getting new nsdata object each time. i'm not sure if sendsynchronousrequest:returningresponse:error: hands autoreleased object don't think so. happens assign memory , don't release in method. next time method called, reassign same pointer new block of memory (nsdata object). memory previously-assigned nsdata leaked because nothing has reference anymore , never released. when release in dealloc:, you're releasing last block made last time called parsing method. make sense?
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Upgrade Eligibility?

need help with itunes 7.7

How to change Apple IDs on iPhones