• 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: Immediate memory release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Immediate memory release


  • Subject: Re: Immediate memory release
  • From: Bob Smith <email@hidden>
  • Date: Tue, 29 Apr 2008 13:33:02 -0700

Use a local autorelease pool, like this:

- (IBAction)Generate:(id)sender
{

  // some code

  for (i = 0; i < count; i++) {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSImage *tempSource = [NSImage imageWithContentsOfFile:sPath[i]];

    // some code

    [pool release];
  }
}


On Apr 29, 2008, at 4:30 AM, 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 (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Immediate memory release (From: Yannick De Koninck <email@hidden>)

  • Prev by Date: transient attributes of NSManagedObject reflected in isUpdated
  • Next by Date: Re: How is "Apple + Ctrl + D" implemented?
  • Previous by thread: Re: Immediate memory release
  • Next by thread: NSTokenField
  • Index(es):
    • Date
    • Thread