Forcing garbage collection, freeing up memory, thrashing
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