Garbage Collection and Profile collection
When Ebean is collecting profiling information it puts a NodeUsageCollector object on each entity bean.
The NodeUsageCollector collects profiling information which essentially is the set of properties for
that bean that where used (read or written).
Q: When does the NodeUsageCollector know when to stop collecting information?
A: For Ebean this occurs via Garbage collection. The finalize is called on the NodeUsageCollector and
at that point it publishes its profiling information back to a AutoFetchListener.
The approach has worked very well for me on the Sun JVM. For applications that run for a short time it should be noted that
garbage collection is not likely to occur. As part of Ebean's shutdown it triggers a GC and collects
any leftover profiling information before writing that to a file.
This works well on the Sun JVM but we should note that triggering a GC is a HINT to the JVM and not a guarantee
that a GC will actually occur. We really DON'T want to be triggering GC (let the JVM do its thing) so Ebean
only does this on shutdown.
|