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: memory problem, advice needed



The problem would presumably be that methods like [NsArray arrayWith...] create autoreleased objects. This means they will not be released until you've finished your for loop.

If this is case, you need to either use methods that don't automatically autorelease things ([[NSArray alloc] initWithArray]) and then manually release things, or create your own autorelease pool around the methods in the function.

However, you do state that trying to release your objects manually doesn't seem to help, so maybe there is something more to it (and goodness knows I'm no threading expert).

Mike.

On 1 Apr 2006, at 06:11AM, Paul Gribble wrote:

I have an app that when the user clicks the "GO" button, a for-loop is
initiated (in a thread) and each run through the for-loop, a function
myFun() is called (not a method, a traditional C function).

within myFun(), are several object creation calls, e.g.

NSArray *myArray = [NSArray arrayWithObjects: myObj1, myObj2, nil];

where myObj1, ... etc are arrays themselves, also defined within myFun().

When I examine the memory footprint as the for-loop progresses, I notice
memory being eaten up continuously at a rapid pace. When I comment out these
object creation lines of code in myFun() and rerun the for loop the memory
issue goes away.


This leads me to believe that when myFun() is called each time in the for
loop, the objects that are created within myFun() are not being released.


I've tried putting [myObj1 release]; [myObj2 release]; ... [myArray
release]; at the end of myFun() but that doesn't seem to help.

Any suggestions? Does this interact with the fact that myFun() is being
called by a method that itself is launched using a thread?


Thanks,

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah% 40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to 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.