[X-Unix] Application 'launch-cache'...

William H. Magill magill at mcgillsociety.org
Wed May 19 09:09:13 PDT 2004


On 19 May, 2004, at 04:29, Kuestner, Bjoern wrote:
> Then start the app. Quit the app. Start it again and it should load
> significantly faster. The effect is quite noticeable on my iBook for 
> many
> apps. Then if I don't use the app for a while starting it again takes 
> just
> as long because it's not in the cache anymore.
>
> OS X uses all available RAM for caching all sorts of things including
> application launches. That's what also confuses people at times when 
> they
> have 1 GB of memory installed and run a memory monitor. After a while 
> RAM
> will fill up to around 90% depending on their work. So they think they 
> have
> a memory leak or some app hogging RAM. But it's just OS X for instance
> keeping stuff in RAM although it's not used anymore just in case the 
> user
> decides otherwise and does use it again. If there's a better way to 
> use the
> RAM for something else OS X will overwrite it.

No cache here, just normal virtual memory management.

What you are describing is the implementation of a LRU - Least Recently 
Used - paging algorithm, as applied to physical memory.

The concept that any program must LOAD at 0,0 in physical memory and 
grow upwards is a holdover from pre-virtual days. While the LOGICAL 
memory addresses of a program normally begin at 0,0, that address may 
be mapped to any convenient page in Physical Memory. The Virtual Memory 
Subsystem handles all of this mapping between physical and logical 
memory, "automagically."  Similarly, logical program memory is not 
necessarily a contiguous block of physical memory, but can be randomly 
assigned to physical pages. All of these issues are dealt with 
"automagically" today by the compilers and the operating system.

So yes, if a system has gobs of free physical memory, the OS will not 
re-use "dirty" pages of physical memory until they have been "cleaned." 
You can call this caching, and in one sense it is, but it is an effect 
of the virtual memory system, not an active caching effort. That is to 
say, it is NOT all of the memory associated with a particular program 
that are kept "alive" as a unit, but rather memory pages are time 
stamped as to their last usage (possibly read, but definitely written) 
and then "re-used" according to those time stamps an their 
"cleanliness." Put another way, it is memory pages which are cached, 
not programs.

There is a garbage collection algorithm which will ultimately "scrub" 
all of those dirty pages in memory and if not recently used, mark them 
as empty, and physical memory usage will go down.

T.T.F.N.
William H. Magill
# Beige G3 - Rev A motherboard - 768 Meg
# Flat-panel iMac (2.1) 800MHz - Super Drive - 768 Meg
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg]- Tru64 5.1a
# XP1000  [Alpha EV6]
magill at mcgillsociety.org
magill at acm.org
magill at mac.com



More information about the X-Unix mailing list