A system for associating a phase with an activation of a computer program
that supports garbage collection include: a plurality of stacks, each
stack including at least one stack frame that includes an activation
count; and a processor with logic for performing steps of: zeroing the
activation count whenever the program creates a new stack frame and after
garbage collection is performed; determining whether an interval has
transpired during program execution; examining each stack frame's content
and incrementing the activation count for each frame of the stacks once
the interval has transpired; detecting the phase whose activation count
is non-zero and associating the phase with the activation; and ensuring
that when the phase ends, an action is immediately performed.Detecting
phases in a running computer program, creates an activation count
associated with each stack frame. The activation count is zeroed whenever
a new frame is created in a stack and incremented for each frame
encountered during periodic intervals. A phase is detected with an
activation whose activation count is non-zero.