Re: dealloc not called for FxPlug
Re: dealloc not called for FxPlug
- Subject: Re: dealloc not called for FxPlug
- From: Roman Kudinov <email@hidden>
- Date: Thu, 25 May 2017 11:17:32 +0300
Pete,
One more approach I used to manage resources was to track their usage.
If a particular resource is not used within, say, 10 last seconds I
deallocate the resource. If it's being used again then I reclaim it.
Yes, we can tell people to exit to clear licenses (and we do), but a better
solution would certainly be advantageous.
It really is more of a problem than waiting for exit. Instead of just
letting things "dangle" at the end, what about some type of cleanup callback
that is traversed (something other than "dealloc"?), to balance the each
call to initWithAPIManager ?
Assuming we'll cleanup upon exit is also not particularly satisfying. Let's
say the user wants to close a project and start another one. It would be
great to have all the plug-ins that have been initialized in one project,
but not used in another, be "undone". Would you like to be told "you need
to close the app to release licenses"? Seems like an overly cumbersome
workaround.
Yes, we can tell people to do that (and we do), but a better solution would
certainly be advantageous.
What about people that keep other kinds of resources around that could b
ereleased? You assume this only need to be cleaned up upon exit, but I
purport there are many other scenarios where this would be useful.
Pete
From: Darrin Cardani <email@hidden>
Date: Tuesday, May 23, 2017 at 9:50 AM
To: Peter Litwinowicz <email@hidden>
Cc: Daniel Walz <email@hidden>, pro-apps-dev
<email@hidden>
Subject: Re: dealloc not called for FxPlug
Pete,
I know this is a pain for you. It’s something I’ve done some work on, but
there are some big architectural things that make it difficult to get this
working how you want. Right now, the only solution I know of is to use an
exit handler (see ‘man atexit’ for more info) when the app quits and release
all remaining licenses that you’re holding on to. (Which, if I recall is
already what you’re doing, isn’t it?)
Darrin
On May 22, 2017, at 4:29 PM, Peter Litwinowicz <email@hidden> wrote:
Darrin,
During shutdown, the apps do not free every piece of memory that they
allocated.
I've asked before and have filed bug reports: –dealloc was NOT be called on
the apiManager object for each time initWithAPIManager invocation.
I complained because we were not having all resource management code being
called properly. In particular we needed to tell our floating license server
(in another process) to release any licenses upon exit, which can only be done
by a deallocation of the apiManager object we create for our plug-in (and
needs to be done for each invocation of initWithApiManager for a balanced set
of calls).
So not calling –dealloc on our apiManager object doesn't give us this chance
to setup and release our licenses in a balanced way.
So what is the proposed proper way for us to "undo" what we did in "init" in
a balanced way?
Pete
From: Pro-apps-dev <pro-apps-dev-bounces+pete=email@hidden>
on behalf of Darrin Cardani <email@hidden>
Date: Monday, May 22, 2017 at 2:25 PM
To: Daniel Walz <email@hidden>
Cc: pro-apps-dev <email@hidden>
Subject: Re: dealloc not called for FxPlug
Daniel,
You should not directly call -dealloc on your ThemeLibrary object. You should
call -release. It probably won’t cause any problems, but it could in theory.
That said, what you are seeing is normal. During shutdown, the apps do not
free every piece of memory that they allocated. Since the operating system
will free all memory used by the app’s process, the apps just quit and let the
OS reclaim the memory rather than manually going through every object and
deallocating them. This significantly speeds up shutdown times for users.
Darrin
On May 22, 2017, at 5:47 AM, Daniel Walz <email@hidden> wrote:
Hi everybody,
I have a FxGenerator plugin and I allocate a C++ class in the init method. I
test that in a project with one instance on the timeline. I get two calls to
init (using NSLog debugging), but only one dealloc when closing Final Cut,
hence my LeakDetector goes off.
Maybe it is due to my limited ObjC knowledge, this is my first ObjC
project...
Is there something I did wrong? Or is it a FinalCut mistake?
Here is the relevant code:
- (id)initWithAPIManager:(id)apiManager
{
(void)@protocol(MyFxPlugRegistration);
self = [super init];
_apiManager = apiManager;
_registeredPlugin = YES;
themeLibrary = [[ThemeLibrary alloc] init];
NSLog (@"created MyFxPlug");
return self;
}
- (void)dealloc
{
NSLog (@"dealloc MyFxPlug");
// Clean up
[themeLibrary dealloc];
[super dealloc];
}
Thanks for helping,
Daniel
--
Daniel Walz | Software Developer
Filmstro | Music that Moves.
www.filmstro.com <http://www.filmstro.com/> | twitter/filmstro
<https://twitter.com/filmstro> | vimeo/filmstro <https://vimeo.com/filmstro>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________ Do not post admin requests to
the list. They will be ignored. Pro-apps-dev mailing list
(email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden