Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

momery leak #27

Closed
uranpro opened this issue Dec 19, 2011 · 5 comments
Closed

momery leak #27

uranpro opened this issue Dec 19, 2011 · 5 comments

Comments

@uranpro
Copy link

uranpro commented Dec 19, 2011

when you set selfReference
self.selfReference = self;
release method will never calls

@TimCinel
Copy link
Owner

There's a line
self.selfReference = nil
which is called when the ActionSheetPicker is dismissed.

If there are other references to self, then dealloc is called and no leaks occur.

Are you actually getting a leak? If so, how? I'm not able to produce a leak, and I get no analyser warnings.

One easy way to test is to place a breakpoint inside the dealloc method.

@uranpro
Copy link
Author

uranpro commented Dec 20, 2011

sorry, i mean dealloc method will never calls.
UIView *v = [[[UIView alloc] init] autorelease];
[[[ActionSheetDatePicker alloc] initWithTarget:nil
successAction:nil
cancelAction:nil
origin:v] release];

@TimCinel
Copy link
Owner

In your example, the ActionSheetTatePicker will deallocate after you call showActionSheetPicker and it is dismissed.

The selfReference is released and set to nil when the ActionSheetPicker is dismissed.

If the ActionSheetPicker is never dismissed (nor presented) then indeed, it won't be released. To avoid this situation, don't create one unless you intend on presenting it.

@TimCinel
Copy link
Owner

UIView *v = [[[UIView alloc] init] autorelease]; ActionSheetDatePicker *datePicker = [[[ActionSheetDatePicker alloc] initWithTarget:nil successAction:nil cancelAction:nil origin:v]; [datePicker showActionSheetPicker]; [datePicker release];

In this case, the ActionSheetPicker will release soon after being dismissed. Set a breakpoint on the dealloc method for verification.

@uranpro
Copy link
Author

uranpro commented Dec 20, 2011

I know.
You need to move line
self.selfReference = self;
to showInView: method

PS: In my example i do not call showAcionSheetPicker, because i want to show you memory leak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants