Here's the basic (highly simplified) code layout. Everything happens
inside the run() method of a thread:
public void run()
{
boolean running = true;
while (running)
{
final Timer.Context allContext = allTimer.time();
final Timer.Context errContext = errTimer.time();
final Timer.Context genContext = genTimer.time();
// get/convert next image
allContext.stop();
if (success) {
genContext.stop();
// stuff
} else {
errContext.stop();
// stuff
}
// set running to false if done
}
}
The context objects are created inside that while loop, which should mean
that the references are gone when each run of the loop ends. If all three
contexts (including the one that is never stopped) are 100% garbage when
the variables go out of scope, without any references maintained within the
Metrics library, then everything should be fine. I've got this code
running now, hoping that there are no problems.
On Thursday, June 1, 2017 at 12:17:10 PM UTC-6, Evan Meagher wrote:
>
> Hello Shawn,
>
> Are references kept for all of the `Timer.Context` objects over the
> lifetime of the program? If so, then they should behave as any other
> objects instantiated by application code, meaning they won't be garbage
> collected until they become unreachable.
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.