__NSAutoreleaseNoPool (): Object 0x753c2f0 of class General autoreleased without pool in place - just a leak

For some time I did not notice the output to the console, and I suddenly noticed a lot of strange errors.

__NSAutoreleaseNoPool(): Object 0x753c2f0 of class General autoreleased with no pool in place - just leaking

__NSAutoreleaseNoPool(): Object 0x753c300 of class __NSArrayM autoreleased with no pool in place - just leaking

I do not know where this is happening?

Change ..

I use this

[self performSelectorInBackground:@selector(startupStuff) withObject:sender];

C statupStuffi have it

General *rdb = [[General alloc] autorelease];
[rdb refreshDBData];

Errors occur soon after the code in the method refreshDBData.

+5
source share
3 answers

Autorelease pools are thread bound. If you create a stream through performSelectorInBackground, you need to create and destroy the auto-advertisement pool for yourself. So you need startupStuff to look like this:

- (void)startupStuff:(id)sender
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // ... everything else you were doing ...

    [pool drain]; //see comment below
}

: , , , ( , iOS) . Apple ():

; , , . , . , .

, . , iPhone, . , ", , ", "... , , , , " - ".

+16

:

General *rdb = [[General alloc] autorelease];

. ; -init, .

+4

[self performSelectorInBackground:@selector(startupStuff) withObject:sender];

-(void)startupStuff:(id)sender
{

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

   General *rdb = [[General alloc] init];

   [rdb refreshDBData];

   [rdb release];

   [pool release];

}

, refreshDBData.. -

0

All Articles