Processes are only removed from the cache when a new process needs to enter the cache (i.e. we never trim the cache when you end a process, only when you start a process).
Every process is placed in the cache when it is loaded - if the cache is full, some processes may be removed.
The cache is considered to be full if the number of processes in the cache exceeds the user's cache quota (defaults to 15).
Active processes are never removed from the cache.
A subprocess is active as long as it's family is active.
When trimming the cache, we remove as many low-priority, inactive processes as need to bring the cache back to the desired size (as determined by the user's cache quota).
While trimming the cache, we will remove all inactive processes that have a priority lower than the user's cache priority, even if the cache is not full.
A user's cache priority defaults to 15.
Since the default priority assigned to each process is 50, all processes are considered equal when we start trimming the cache.
If you have a low priority process, it will be trimmed before higher priority processes.
If you have a high priority process, it will tend to stay in the cache longer than low priority processes.
Since the default cache level for a user is 15, processes with a priority lower than 15 will not stay in the cache.
The cache can hold more processes than the user is allowed - this happens when the user has more active processes.
The documentation is wrong when it states that related and detached processes are not cached.