FROM : mmalcolm crawford
DATE : Mon Dec 20 21:15:53 2004
On Dec 20, 2004, at 11:04 AM, Julian Pellico wrote:
>> Why do you check this in the first place? Do you suspect that there is
>> a leak? What made you suspicious of that? Have you tracked it with
>> ObjectAlloc?
> Of course; otherwise I wouldn't be printing out retain counts. I do
> exactly these things with the MyView:
> - allocate a MyViewController which contains a MyView
> - add the MyViewController to an array
> - release the MyViewController
> - make the MyView a subview of another custom view
> - call removeFromSuperview on the MyView
> - remove the MyViewController from the array
> The MyViewController gets dealloc'ed, but the MyView doesn't.
>
There are several places here where you might be making a mistake in
memory management. Does your MyViewController retain the MyView? If
so, does it retain it in addition to alloc-ing it? Does it release it
in its dealloc method?
>> My advice is always that you shouldn't try to track retain count like
>> that. What if it's autoreleased?
> It would hardly be safe for the frameworks to autorelease it. I might
> want that NSView well past the end of the run loop.
>
It's not clear in what sense this would be unsafe. It would be
perfectly reasonable for a view removed from a superview to be
autoreleased rather than released -- see John's reply (Dec 20, 2004, at
11:50 AM).
mmalc
DATE : Mon Dec 20 21:15:53 2004
On Dec 20, 2004, at 11:04 AM, Julian Pellico wrote:
>> Why do you check this in the first place? Do you suspect that there is
>> a leak? What made you suspicious of that? Have you tracked it with
>> ObjectAlloc?
> Of course; otherwise I wouldn't be printing out retain counts. I do
> exactly these things with the MyView:
> - allocate a MyViewController which contains a MyView
> - add the MyViewController to an array
> - release the MyViewController
> - make the MyView a subview of another custom view
> - call removeFromSuperview on the MyView
> - remove the MyViewController from the array
> The MyViewController gets dealloc'ed, but the MyView doesn't.
>
There are several places here where you might be making a mistake in
memory management. Does your MyViewController retain the MyView? If
so, does it retain it in addition to alloc-ing it? Does it release it
in its dealloc method?
>> My advice is always that you shouldn't try to track retain count like
>> that. What if it's autoreleased?
> It would hardly be safe for the frameworks to autorelease it. I might
> want that NSView well past the end of the run loop.
>
It's not clear in what sense this would be unsafe. It would be
perfectly reasonable for a view removed from a superview to be
autoreleased rather than released -- see John's reply (Dec 20, 2004, at
11:50 AM).
mmalc
| Related mails | Author | Date |
|---|---|---|
| Julian Pellico | Dec 19, 08:29 | |
| j o a r | Dec 19, 09:51 | |
| Julian Pellico | Dec 20, 20:04 | |
| John C. Randolph | Dec 20, 20:50 | |
| mmalcolm crawford | Dec 20, 21:15 | |
| John C. Randolph | Dec 20, 22:26 |






Cocoa mail archive

