Skip navigation.
 
mlRe: Main window disappears. Sometimes.
FROM : Bill Bumgarner
DATE : Mon Jun 02 19:50:13 2008

On Jun 2, 2008, at 10:31 AM, Michael Vannorsdel wrote:
> On Jun 2, 2008, at 5:24 AM, Francis Perea wrote:
>

>> Hi Graham, thanks for your reply.
>>
>> I didn't know I could set any memory setting trough Interface 
>> Builder!
>>
>> After your question I looked into and I've seen that it states as 
>> Beffered.
>>
>> I've tried to use the Retained option, thinking that this way I 
>> shouldn't use the retain message, but with Retained the windows 
>> appears but doesn't accept any interaction.
>>
>> I'd take a deep look into de Memory Management doc you suggest.


While learning the retain/release paradigm is certainly useful, it is 
considerably more complex than GC.  It is also unnecessary while 
learning Cocoa.  Specifically, GC is intended to be a production 
quality solution that you can use in your Cocoa applications, without 
exception.  In Leopard, there have been a handful of bugs and they 
have been addressed through software updates -- not surprising given 
the rather sweeping and intrusive set of changes needed to support 
GC.  And GC will get better / faster in future releases.

If your window is sometimes disappearing under GC -- is sometimes 
being collected prior to when you think it should be -- that means 
that the collector doesn't believe that the window object is being 
used by your application.  To the collector, being visible doesn't 
count as "in use".

In GC, "in use" is defined entirely by whether or not you have a 
reference to an object.  A pointer to the object somewhere in scanned 
memory (of which, any Objective-C object's data will be "scanned 
memory").

So, when your NIB is loaded, who hangs on to a reference to the 
window.  It doesn't sound like anything does.  The easiest way to fix 
this would be to create an outlet in your file's owner and connect 
that outlet as a reference to the window.  Now, as long as the file's 
owner has a strong reference to *it*, then your window sticks around.

Note that in document based applications, the NSDocument 
infrastructure takes care of keeping things referenced that need to 
stick around.

This sounds like you have a non-document based application and your 
main window is disappearing out from under you.  From the documentation:

>>>> Since the collector follows strong references from root objects, 
>>>> and treats as garbage all objects that cannot be reached from a 
>>>> root object, you must ensure that there are strong references to 
>>>> all top-level objects in a nib file (including for example, stand-
>>>> alone controllers)—otherwise they will be collected. You can 
>>>> create a strong reference simply by adding an outlet to the 
>>>> File's Owner and connecting it to a top-level object. (In 
>>>> practice this is rarely likely to be an issue.)


b.bum_______________________________________________

Cocoa-dev mailing list (<email_removed>)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>

Related mailsAuthorDate
mlMain window disappears. Sometimes. Francis Perea Jun 2, 09:58
mlRe: Main window disappears. Sometimes. Wayne Packard Jun 2, 10:06
mlRe: Main window disappears. Sometimes. Francis Perea Jun 2, 10:36
mlRe: Main window disappears. Sometimes. Michael Vannorsdel Jun 2, 10:45
mlRe: Main window disappears. Sometimes. Francis Perea Jun 2, 11:05
mlRe: Main window disappears. Sometimes. Michael Vannorsdel Jun 2, 11:19
mlRe: Main window disappears. Sometimes. Paul Sargent Jun 2, 11:50
mlRe: Main window disappears. Sometimes. Graham Cox Jun 2, 13:11
mlRe: Main window disappears. Sometimes. Francis Perea Jun 2, 13:16
mlRe: Main window disappears. Sometimes. Francis Perea Jun 2, 13:24
mlRe: Main window disappears. Sometimes. Michael Vannorsdel Jun 2, 19:31
mlRe: Main window disappears. Sometimes. Bill Bumgarner Jun 2, 19:50
mlRe: Main window disappears. Sometimes. Paul Sargent Jun 2, 20:35
mlRe: Main window disappears. Sometimes. mmalc crawford Jun 2, 20:40
mlRe: Main window disappears. Sometimes. Paul Sargent Jun 2, 20:55
mlRe: Main window disappears. Sometimes. Francis Perea Jun 2, 22:48
mlRe: Main window disappears. Sometimes. Bill Bumgarner Jun 2, 22:50
mlRe: Main window disappears. Sometimes. Henry McGilton (St… Jun 3, 04:19
mlRe: Main window disappears. Sometimes. William Bumgarner Jun 3, 04:47
mlRe: Main window disappears. Sometimes. Michael Ash Jun 3, 06:50
mlRe: Main window disappears. Sometimes. Sean McBride Jun 3, 17:28
mlRe: Main window disappears. Sometimes. Stephane Sudre Jun 3, 18:20
mlRe: Main window disappears. Sometimes. Bill Bumgarner Jun 3, 18:29
mlRe: Main window disappears. Sometimes. Stephane Sudre Jun 3, 18:56
mlRe: Main window disappears. Sometimes. Andy Lee Jun 3, 19:02
mlRe: Main window disappears. Sometimes. Hamish Allan Jun 3, 19:22
mlRe: Main window disappears. Sometimes. Bill Bumgarner Jun 3, 19:25