Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unloading bundled class



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


References: 
 >Re: unloading bundled class (From: Andreas Wolf <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.