FROM : Shawn Erickson
DATE : Mon Jun 19 17:35:33 2006
On Jun 19, 2006, at 4:02 AM, <cocoa> <cocoa> wrote:
> Shawn Erickson <<email_removed>> wrote :
>
>> On Jun 18, 2006, at 8:02 PM, Drarok Ithaqua wrote:
>>
>> > For sake of simplicity, let's assume I want to swap the
>> contents of
>> > two windows, mainWindow and playlistWindow.
>
> From the Apple docs:
> The receiver retains the new content view and owns it thereafter.
> aView is resized to fit precisely within the content area of the
> NSWindow object. You can modify the content view’s coordinate
> system through its bounds rectangle, but can’t alter its frame
> rectangle (that is, its size or location) directly.
>
> This method causes the old content view to be released; if you plan
> to reuse it, be sure to retain it before sending this message and
> to release it as appropriate when adding it to another NSWindow
> object or NSView.
>
> No mention of auto-releasing there, but something strange is
> certainly going on.
Nothing strange is likely taking place and an autorelease is
considered a release. So don't assume implementation from the
documentation. Just stick to the simple Cocoa memory management rules
and try not to debug things using retain counts.
> The other problem is that there seems to be weirdness with the
> NSMovieView, as the contents of the playlistWindow appears in the
> mainWindow just fine, but the MovieView disappears. When I swap
> them back, it appears OK in the mainWindow again.
> Doesn't seem to like moving between windows.
Something is likely wrong in how you are swapping things around (or a
bug in the framework but those happen very seldom). I move views
between windows all the time (just need to make sure you are moving
the correct view... some items you drop from IB into a nib are in
fact contained in a parent view... say a scroller view).
> But that still doesn't resolve my retainCounts going screwy. Is
> there a way to fine out what objects are retaining others?
Often best to audit your code and make sure you are balancing every
retain with a retain/autorelease and not releasing/autorelease
anything that you didn't alloc, copy, or retain yourself.
If you are crashing because of a memory issue search for and enable
NSZombie support [1, 2] also look at using ObjectAlloc [3] or
OmniGroup's OmniObjectMeter [4].
-Shawn
[1] <http://developer.apple.com/technotes/tn2004/tn2124.html>
[2] <http://www.cocoadev.com/index.pl?DebuggingAutorelease>
[3] <http://developer.apple.com/documentation/Performance/Conceptual/
ManagingMemory/Articles/FindingPatterns.html#//apple_ref/doc/uid/
20001882-97995-TPXREF162>
[4] <http://www.omnigroup.com/developer/omniobjectmeter/> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (<email_removed>)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
This email sent to <email_removed>
DATE : Mon Jun 19 17:35:33 2006
On Jun 19, 2006, at 4:02 AM, <cocoa> <cocoa> wrote:
> Shawn Erickson <<email_removed>> wrote :
>
>> On Jun 18, 2006, at 8:02 PM, Drarok Ithaqua wrote:
>>
>> > For sake of simplicity, let's assume I want to swap the
>> contents of
>> > two windows, mainWindow and playlistWindow.
>
> From the Apple docs:
> The receiver retains the new content view and owns it thereafter.
> aView is resized to fit precisely within the content area of the
> NSWindow object. You can modify the content view’s coordinate
> system through its bounds rectangle, but can’t alter its frame
> rectangle (that is, its size or location) directly.
>
> This method causes the old content view to be released; if you plan
> to reuse it, be sure to retain it before sending this message and
> to release it as appropriate when adding it to another NSWindow
> object or NSView.
>
> No mention of auto-releasing there, but something strange is
> certainly going on.
Nothing strange is likely taking place and an autorelease is
considered a release. So don't assume implementation from the
documentation. Just stick to the simple Cocoa memory management rules
and try not to debug things using retain counts.
> The other problem is that there seems to be weirdness with the
> NSMovieView, as the contents of the playlistWindow appears in the
> mainWindow just fine, but the MovieView disappears. When I swap
> them back, it appears OK in the mainWindow again.
> Doesn't seem to like moving between windows.
Something is likely wrong in how you are swapping things around (or a
bug in the framework but those happen very seldom). I move views
between windows all the time (just need to make sure you are moving
the correct view... some items you drop from IB into a nib are in
fact contained in a parent view... say a scroller view).
> But that still doesn't resolve my retainCounts going screwy. Is
> there a way to fine out what objects are retaining others?
Often best to audit your code and make sure you are balancing every
retain with a retain/autorelease and not releasing/autorelease
anything that you didn't alloc, copy, or retain yourself.
If you are crashing because of a memory issue search for and enable
NSZombie support [1, 2] also look at using ObjectAlloc [3] or
OmniGroup's OmniObjectMeter [4].
-Shawn
[1] <http://developer.apple.com/technotes/tn2004/tn2124.html>
[2] <http://www.cocoadev.com/index.pl?DebuggingAutorelease>
[3] <http://developer.apple.com/documentation/Performance/Conceptual/
ManagingMemory/Articles/FindingPatterns.html#//apple_ref/doc/uid/
20001882-97995-TPXREF162>
[4] <http://www.omnigroup.com/developer/omniobjectmeter/> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (<email_removed>)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Drarok Ithaqua | Jun 19, 05:02 | |
| Shawn Erickson | Jun 19, 05:22 | |
| Shawn Erickson | Jun 19, 17:35 | |
| Drarok Ithaqua | Jun 19, 21:41 |






Cocoa mail archive

