Re: unloading bundled class
Re: unloading bundled class
- Subject: Re: unloading bundled class
- From: Stefan Arentz <email@hidden>
- Date: Fri, 18 May 2001 10:42:40 +0200
On Friday, May 18, 2001, at 02:54 AM, Andreas Wolf wrote:
>
Hi,
>
>
Thanks for all the helpful answers to my previous questions.
>
Here is another one:
>
>
Is there a save way to get rid of all of a bundle's allocated memory?
>
(Just as if you'd quit the bundle).
>
>
I have a:
>
>
bundle=[NSBundle bundleWithPath::[[NSBundle mainBundle]
>
pathForResource: componentName ofType::@"bundle"]];
>
>
if(componentClass=[bundle principalClass])
>
{
>
componentInstance = [[componentClass alloc] init];
>
[componentInstance show:nil];
>
// .. do things with componentInstance
>
}
>
>
>
Now, it figures that I could get rid of the bundled componentInstance
>
by releasing it.
>
>
[componentInstance release];
>
componentInstance = nil;
>
However, top shows that I don't really get rid of all allocated memory,
>
since the size of my program increases everytime I load the bundle and
>
never actually decreases (although I know that the componentInstance
>
gets the release message.
You could try wrap the above code in a NSAutoreleasePool, that way you
can control the time when the autoreleased objects are freed. There's an
example in the NSAutoreleasePool I think.
Also, what might be happening here is that the Objective C runtime
cannot unload the class. I'm not familiar with the details of the
runtime, but there's a good change that it cannot unload classes.
Stefan