bb.util
Interface MemoryMonitorListener

All Superinterfaces:
Closeable
All Known Implementing Classes:
MemoryMonitor.UnitTest.ListenerTest, MemoryMonitorListenerImpl

public interface MemoryMonitorListener
extends Closeable

Interface for receiving events from MemoryMonitor.

As with typical listener classes, implementations should also catch and handle any Throwables generated inside these methods since MemoryMonitor has little idea how to handle them.

Implementations should be multithread safe, since MemoryMonitor makes no guarantee which thread(s) will call these methods.

Author:
Brent Boyer

Method Summary
 void close()
          Called when the associated MemoryMonitor is being closed.
 void onMemoryLow(MemoryState state)
          Called whenever the associated MemoryMonitor instance first detects the low memory state when previously it had detected a not low memory state.
 void onMemoryNotLow(MemoryState state)
          Called whenever the associated MemoryMonitor instance first detects a not low memory state when previously it had detected the low memory state.
 void onMemoryState(MemoryState state)
          Called whenever the associated MemoryMonitor instance has measured a new memory state.
 void onMonitoringError(Throwable t)
          Called when the associated MemoryMonitor instance has detected some error while monitoring.
 void onMonitoringStarted()
          Called when the associated MemoryMonitor instance has just started monitoring.
 void onMonitoringStopped()
          Called when the associated MemoryMonitor instance has just stopped monitoring.
 

Method Detail

onMonitoringStarted

void onMonitoringStarted()
Called when the associated MemoryMonitor instance has just started monitoring. This method will be called repeatedly if MemoryMonitor goes thru multiple start and stop cycles.


onMonitoringStopped

void onMonitoringStopped()
Called when the associated MemoryMonitor instance has just stopped monitoring. This method will be called repeatedly if MemoryMonitor goes thru multiple start and stop cycles.


onMonitoringError

void onMonitoringError(Throwable t)
Called when the associated MemoryMonitor instance has detected some error while monitoring.

Parameters:
t - the Throwable which caused the error

onMemoryState

void onMemoryState(MemoryState state)
Called whenever the associated MemoryMonitor instance has measured a new memory state. This method will be called repeatedly.

Parameters:
state - the MemoryState which was just measured

onMemoryLow

void onMemoryLow(MemoryState state)
Called whenever the associated MemoryMonitor instance first detects the low memory state when previously it had detected a not low memory state. This method will be called repeatedly if the memory cycles in and out of low memory.

Parameters:
state - the MemoryState for which low memory was just detected

onMemoryNotLow

void onMemoryNotLow(MemoryState state)
Called whenever the associated MemoryMonitor instance first detects a not low memory state when previously it had detected the low memory state. This method will be called repeatedly if the memory cycles in and out of low memory.

Parameters:
state - the MemoryState for which not low memory was just detected

close

void close()
Called when the associated MemoryMonitor is being closed.

Specified by:
close in interface Closeable