views:

26

answers:

1

Hi friends,

I am using shared delegate for getting data on url connection. I getting a memory leak on my code. Can anybody please tell me what i have done wrong. Thanks in advance.

Analyser Warning:

/Users/sathish/Documents/XXX 20100908 ManageMem/Classes/Data Download/XXX DataConnect.m:68:22: warning: Potential leak of an object allocated on line 68 gXXXDataConnect = [[XXXDataConnect alloc] customInit] ;


XXXDataConnect.h

  • (XXXDataConnect*)sharedXXXDataConnect;

XXXDataConnect.m

  • (XXXDataConnect *)sharedXXXDataConnect { if(gXXXDataConnect == nil)

    gXXXDataConnect = [[XXXDataConnect alloc] customInit] ;

    return gXXXDataConnect ;

}

Regards, sathish

A: 

Well, you're never deallocating your XXXDataConnect you've just allocated. If you don't deallocate it, who will?

Assuming this is Objective-C, I think you need a return [gXXXDataConnect autorelease] as your end-of-function. http://www.otierney.net/objective-c.html#retain might be a helpful link here.

Kistaro Windrider
Thanks for your answer kistaro but still that memory warning there even after putting return [gXXXDataConnect autorelease]
sathish kumar

related questions