Mantis - Quercus
Viewing Issue Advanced Details
3457 major always 04-24-09 09:10 04-26-09 10:12
new 4.0.0  
0003457: Objects without TTLs still disappear from APC
Whenever I leave Quercus running on a test server for an extended period, I eventually find that the application log full of error messages about its configuration data being missing from APC (the config data is loaded at app startup.) I've configured APC to be large enough that it should never have to expire any entries via LRU, and in any case these configuration entries are pretty frequently used.

I believe the root cause is that the values in APC are stored as UnserializeCacheEntry objects, which use soft references. So what's probably going on is that the garbage collector runs at some point and decides it needs to reclaim the memory from some or all of those soft references -- which is of course done without regard to where in the LRU queue those objects are. That is, an entry that gets used in every request is nearly as likely to be reaped as one that never gets used at all.

There should be a way of making an object non-reapable, though obviously there's value in letting the GC clean up objects that can safely go away so I'm not suggesting getting rid of that aspect of Quercus' APC implementation altogether. (That said, given a choice between no GC reaping of APC objects and the current situation, the former would be preferable.)

Maybe one way to tell the difference is by TTL? An APC entry with a nonzero TTL is probably safe to let the GC get rid of, whereas one with a zero TTL may be very expensive or impossible to recompute on the fly.

04-26-09 10:12   
A temporary workaround is to use the -XX:SoftRefLRUPolicyMSPerMB option, which controls how long soft references are retained after last access. The default is 1000. But obviously that option affects *all* soft references, not just the APC ones.