Re: memory management question
Re: memory management question
- Subject: Re: memory management question
- From: Shawn Erickson <email@hidden>
- Date: Fri, 19 Mar 2004 14:21:29 -0800
On Mar 18, 2004, at 3:36 PM, matt neuburg wrote:
My app reads lots of TIFFs from disk. As it does this, I can see (with
MemoryStick) that the amount of the computer's "inactive" memory goes
way up
- that is, more and more RAM is being allocated to "inactive" memory,
until
RAM fills up (the amount of "free" memory drops to near zero). When
the app
is done, this memory is not given back.
This is normal, it is the UBC (universal buffer cache) attempting to
cache data that may possibly be used again in an attempt to avoid disk
or network I/O.
My guess is that this memory is a caching of the tiff files from disk.
The
reason for this guess is in part that if I run my app again, it all
happens
much faster and there is no sound of the disk being read.
What I'd like to do is give back the memory after I'm done with each
file. I
have tried all the Cocoa tricks I can think of (autorelease pools
everywhere, explicit init and release wherever possible, and so forth)
but
nothing helps.
You really don't need to give it "back" because it isn't really taken.
The UBC is simply using available pages in physical RAM to hold onto
information. If someone needs a page and a free one isn't available
then an inactive one will get used (since it is caching file data no
page out is needed, it just zeros it and returns the page like it would
if it was a free page). You really don't need to concern yourself with
this (unless you really really want to avoid using the UBC for some
reason).
Having lots of free RAM on your system not being used for something is
a waste of RAM and this caching attempts to make the most of it without
causing issues because if memory is needed for active data inactive
stuff is tossed out the window.
In fact, this is apparently not a Cocoa memory management
issue - I'm not leaking memory, AFAIK - it's a system memory management
issue. It's like I'm fighting the virtual memory system.
Is what I'd like to do reasonable / possible? Thx - m.
If you are dealing with mapped files I believe you can tell the OS to
by pass caching it in the UBC.
-Shawn
_______________________________________________
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.