• 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
Forcing garbage collection, freeing up memory, thrashing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Forcing garbage collection, freeing up memory, thrashing


  • Subject: Forcing garbage collection, freeing up memory, thrashing
  • From: "Sean McBride" <email@hidden>
  • Date: Tue, 4 Nov 2008 13:46:25 -0500
  • Organization: Rogue Research

Hi all,

I have a 64 bit, Cocoa, GC app.  It loads many large bitmap files.  Each
is about 500 MiB, and the user may want to load about 50 of them.  When
each file is opened, I read the entire file, then downscale the image to
a smaller resolution.  I then no longer need the large image.

Basically my code is like:

- (void)openFiles:(NSArray*)filePaths
{
  for each path in filePaths
    load large image
    downsample
    force collection
}

I call:

objc_collect (OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE);

to force the collection.  I've breaked in finalize, and forcing the
collection does work.

However, Activity Monitor still shows my 'Real Memory' growing very
large.  It doesn't fall back until (I think) the next run through the
run loop.

When physical memory is exhausted, the machine thrashes badly.  If I
change my implementation to load only 1 file, then let the runloop
continue, then load the next file, etc. I never even exhaust my physical
memory.

Why is that?

(Yes, I know it would be better to not block the main thread with such a
long task, but this app is for in-house, so it's ok.)

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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

  • Follow-Ups:
    • Re: Forcing garbage collection, freeing up memory, thrashing
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: Xml
  • Next by Date: Re: CALayer contents memory leak
  • Previous by thread: Re: View swapping questions
  • Next by thread: Re: Forcing garbage collection, freeing up memory, thrashing
  • Index(es):
    • Date
    • Thread