Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C object-leak error
    primarykey
    data
    text
    <p>For the program below i get the following error- Potential leak of an object allocated on line 50. Line 50 points to this line-- self.receivedData = [[NSMutableData data] retain]; I tried to release receiveData after this statement but that gives me an error "object sent autorelease too many times." I am not sure if i am doing it the right way.Please help!</p> <pre><code> - (void)viewDidLoad { NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://{your ip}:8080/activiti-rest/service/process-definitions?start=0&amp;size=10&amp;sort=id&amp;order=asc"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { self.receivedData = [[NSMutableData data] retain]; } else { UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [connectFailMessage show]; [connectFailMessage release]; } [theConnection autorelease]; } </code></pre> <p><b>Edit</b> : In the header file it is declared as <code>@property(nonatomic,assign) NSMutableData *receivedData;</code> <br/> <b>New</b> It works after i removed this line[theConnection autorelease]. I kept the assign property as is in the header file and added the [self.receiveData release] like you asked.It did not work earlier because i kept this line [theConnection autorelease].I added it because i was wondering if i have to release theConnection object also.Can you please explain why that doesn't have to released?It is not released anywhere in the code and it still works??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload