• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: memory problem, advice needed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory problem, advice needed


  • Subject: Re: memory problem, advice needed
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 1 Apr 2006 09:59:23 +0100

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:
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: This email sent to email@hidden
  • Prev by Date: Re: Help in 2 Diamensional Array
  • Next by Date: String memory leak
  • Previous by thread: Re: Help in 2 Diamensional Array
  • Next by thread: Re: memory problem, advice needed
  • Index(es):
    • Date
    • Thread