| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| Hi I am writing an ObjectiveC framework. A user of my framework is complaining of a memory leak. There is inded a memory leak.. Here is what happens. A file reader object takes a list of file names to be read in. the file reader object returns an NSArray of Image objects. The file reader deallocation method is called. However I do not see any calls to the image objects deallocation method. - (NSArray *) readFiles:(NSArray *)fileNames { int n = [fileNames count]; NSMutableArray *ret = [NSMutableArray arrayWithCapacity:n]; for (int i=0; i < n; i++) { Image * img = [self readFile:[fileNames objectAtIndex:i]]; if (img != nil) [ret addObject:img]; } return ret; } I was told that the NSMutableArray would actually be responsible for the destruction of the objects it contained... Perhaps I am misinformed? As a work around I have suggested that the user iterate through the NSMutableArray and deallocate the images then deallocate the NSMutableArray... There seems to be a few things that are bothering me here: 1) Perhaps the file reader object should keep the pointer to the NSArray it allocated and deallocate it in its deallocation method (along with the contents of the NSArray) 2) I'm not sure that just because the file reader object is finished its task that the images are no longer needed.. 3) Is it true that the the NSMutableArray should have done the clean up when it went out of scope? Thoughts please. |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.