@ThreadSafe
public final class MemoryLogger
extends Object
implements Runnable
Used to log memory informations. These informations include the maximum amount of memory available to the JVM, the total amount actually allocated to the JVM and the amount of that memory available for future allocated objects. The logging may be triggered by a call or activated on an interval.
Modifier and Type | Method and Description |
---|---|
void |
activate(Optional<ElapsedTime> logInterval)
Activates.
|
void |
deactivate()
Deactivates.
|
static MemoryLogger |
getInstance()
Gets the singleton instance.
|
static void |
logMemoryInfo()
Logs memory informations.
|
void |
onMidnightEvent()
Called on midnight event.
|
void |
run() |
@Nonnull @CheckReturnValue public static MemoryLogger getInstance()
public static void logMemoryInfo()
public void activate(@Nonnull Optional<ElapsedTime> logInterval)
Begins by logging memory informations. If a log interval is present, ensure that logging will continue on that interval, starting a new thread if needed. If logging was already active, the previous interval is saved on a stack.
logInterval
- The optional elapsed time between logs.public void deactivate()
Removes the current activation and activates the previous one if present. Logs memory informations a last time for the removed activation.
public void onMidnightEvent()
If this is the first call for the day, logs memory informations.
public void run()
run
in interface Runnable
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.