Re: memory problem, advice needed
Re: memory problem, advice needed
- Subject: Re: memory problem, advice needed
- From: Paul Gribble <email@hidden>
- Date: Sat, 01 Apr 2006 00:40:22 -0500
- Thread-topic: memory problem, advice needed
I have created my own autorelease pool for the method that is threaded.
However within that method a C function myFun() is (repeatedly) called, and
inside myFun() is where objects are created.
I don¹t understand how to ensure the objects created in myFun() are freed up
by the time myFun() is over
Here¹s a skeleton of my situation:
when the user hits ³GO² button the action method invokes:
[NSThread detachNewThreadSelector:@selector(goEngine:) toTarget:self
withObject:nil];
within the goEngine method, the following happens:
for (i=1; i<1000; i++) {
int myResult;
myResult = myFun(someInput, someMoreInput);
}
then within myFun() the following sorts of things happen:
NSArray *myBigArray = [NSArray arrayWithObjects: mySmallArray1,
mySmallArray2 ,nil];
How do I ensure that when myFun() ends, myBigArray is released?
Thank you for any suggestions,
On 4/1/06 12:22 AM, "Kevin Callahan" <email@hidden> wrote:
> Hi Paul .. have you looked at this:
>
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_clas
> sic/Classes/NSAutoreleasePool.html>
>
> Kevin
>
> Some of my favorite guitar recordings from GHA available at iTunes Music
> Store ...
> Music: http://www.kevincallahan.org/gharecords/Guitar.html
> Cocoa: http://www.kevincallahan.org/software/accessorizer.html
> Lessons: http://www.kevincallahan.org/teaching.html
>
>
> On Mar 31, 2006, at 9:11 PM, 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:
>>
>> This email sent to email@hidden
>>
>
>
>
>
>
--
Paul L. Gribble, Ph.D.
Assistant Professor
Dept. Psychology
University of Western Ontario
London, Ontario
Canada N6A 5C2
Tel. +1 519 661 2111 x82237
Fax. +1 519 661 3961
email@hidden
http://bubba.ssc.uwo.ca
_______________________________________________
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