GUI-less applications and autorelease pool never deallocated ?
GUI-less applications and autorelease pool never deallocated ?
- Subject: GUI-less applications and autorelease pool never deallocated ?
- From: Yann Bizeul <email@hidden>
- Date: Sun, 4 May 2003 18:17:12 +0200
Hello list.
I'm working on an application with NSUIElement (no Dock icon) and no
configuration panel, since it is done via a prefPane.
This application just opens borderless windows and put things in it.
Now, my problem is that lots of variables does not seem to be
deallocated, I have a lot of things in ObjectAlloc that received init
and autorelease, but stay here.
So I think about the way autorelease works, and saw that it is
deallocated on each event loop, but I do not know if my application has
a sollicited event loop because there is no user interaction, just
NSTimers to launch methods and update windows.
Intereting thing : If I click in one of the windows (effect-less clic)
or move finder windows on the application's window, it seems some
events are generated and those objects are deallocated. I can not keep
things like this because this application can stay open in background
for a long time while nobody is using the machine.
So I tried to avoid all autorelease pool usage in my allocations, but
1/ Does Cocoa objects internal methods makes use of autorelease, in
this case, this is painless.
2/ How do I, for example, create a NSColor object without using
convenience methods ?? It seems there are object for which we can not
avoid autorele pool.
Then I tried to stack my own autorelease pool, without success, and
there is a problem, I can have multiple instance of the same object
generating variables, so, when first starts, it creates his pool,
create a NSColor, which is added to the created pool, and, before
finish, another object is instanciated, and creates his own pool, now,
what I understant is is that the first object creates a "temporary"
variable, this one will be added to second's object created pool.
Finally, objects could be deallocated before the end of execution, that
does not seem coherent to me.
I think about using thread, since each thread owns his own autorelase
pool, what do you think about this ?
So for now, I took a look at NSEvent methods, and tried to add this
when running my application :
[ NSEvent startPeriodicEventsAfterDelay:0 withPeriod:60 ];
Objects are now really deallocated, But this seems very ugly to me and
does not seem to work for a long period of time.
So I would like to know if there is a way to handle this.
How people plays with autorelease while there in no events sent to/by
the application.
Thanks for your help
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.