Hi,

Calling -[NSObject release] is almost never a guarantee that your object will be deallocated. By releasing tempSource in your code you're simply stating that you no longer need that object and that Cocoa can free up the memory taken by the object **when appropriate** (i.e., when nobody else is holding on to (retaining) the object). We'd have to know what you're doing in between object creation and release, as your tempSource instances are probably being retained inside some other method that you're calling and then autoreleased, causing them to only be dealloc'ed when the NSAutoreleasePool instance managed by the event loop gets drained/released.

--
João Pavão



On 2008/04/29, at 12:30, Yannick De Koninck wrote:

Hi everybody,

I am writing an application where, at some point in time, the user clicks a button and for a great amount of images the average pixel values are calculated and stored in an array.
Basically this looks like this:

-(IBAction)Generate:(id)sender
{

        // some code

for (i = 0; i < count; i++)
                {
NSImage* tempSource = [[NSImage alloc] initWithContentsOfFile:sPath[i]];
        // some code
        [tempSource release];
}

}


When debugging with ObjectAlloc i found that the memory release does not happen when the release message is sent but only after the Generate function is done. So instead of allocating, deallocating, allocating, deallocating... the application keeps allocating memory and only releases it afterwards. This becomes a big problem when the amount of loaded pictures rises. Is there a way to force the memory manager to free the memory when the release message is sent instead of after the call? Or can i solve this problem in another way?
Thank you very much,
Yannick, Belgium
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jpavao-lists%40sericaia.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to