Re: Some Questions...
Re: Some Questions...
- Subject: Re: Some Questions...
- From: matt neuburg <email@hidden>
- Date: Sun, 20 Jun 2004 09:33:45 -0700
On Sat, 19 Jun 2004 22:45:54 -0400, Jerry LeVan <email@hidden> said:
>
The app can ask for a directory from a user, it then creates
>
a thumbnail of every graphic that the appkit understands and
>
displays them in a scrolling list. Clicking on a thumb causes
>
the image to be shown is a larger frame with a zoom slider
>
for controlling the size.
>
>
I am processing the thumbs in a "tight" loop. Watching "top" while
>
the program grinds away processing the images into thumbs I can
>
watch the VM size growth to over 1GIG, this slows things down as
>
swapping/paging activity increases.
>
>
After the thumbs are processed memory usage drops to a very acceptable
>
level.
>
>
I think the problem is that "released" images don't get claimed in
>
a timely manner...
>
>
***********
>
Is there a "simple" strategy for dealing with this problem? ( I have
>
yet to use threads in Cocoa...).
>
***********
My app does much the same thing so I had to grapple with the same memory
management issues. I presume (from the fact that you say memory usage drops
afterwards) that you are already using
fcntl(fd, F_NOCACHE, 1);
fcntl(fd, F_RDAHEAD, 1);
That was most of the battle for me right there. So, the only things I can
suggest after that are:
(1) Manage memory yourself as much as possible, i.e. don't make any calls in
your loop that generate auto-released objects; instead, use the alloc-init
type of call and release the objects manually. Just in case, though, also
make an NSAutoReleasePool at the start of your loop and release it at the
bottom of every iteration.
(2) Try to avoid using NSImage. You can open an image directly from disk as
an NSBitmapImageRep and often this is all you need. If you must use an
NSImage, recache it just before you release it.
(3) Use MallocDebug.
m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.