RmmEventHandler#

public interface RmmEventHandler#

A callback interface for RMM memory allocation events.

Notified of allocation failures and threshold crossings, and of every allocation and deallocation when debug mode is enabled. Register a handler with Rmm.setEventHandler(RmmEventHandler).

Method Summary

getAllocThresholds()

Get the memory thresholds that will trigger onAllocThreshold(long) to be called when one or more of the thresholds is crossed during a memory allocation.

getDeallocThresholds()

Get the memory thresholds that will trigger onDeallocThreshold(long) to be called when one or more of the thresholds is crossed during a memory deallocation.

onAllocated(long size)

Invoked after every memory allocation when debug mode is enabled.

onAllocFailure(long sizeRequested)

Deprecated. Invoked on a memory allocation failure.

onAllocFailure(long sizeRequested, int retryCount)

Invoked on a memory allocation failure.

onAllocThreshold(long totalAllocSize)

Invoked after an RMM memory allocate operation when an allocate threshold is crossed.

onDeallocated(long size)

Invoked after every memory deallocation when debug mode is enabled.

onDeallocThreshold(long totalAllocSize)

Invoked after an RMM memory deallocation operation when a deallocate threshold is crossed.

Methods

public default boolean onAllocFailure(long sizeRequested) Deprecated#

Invoked on a memory allocation failure.

Deprecated:

deprecated in favor of onAllocFailure(long, boolean)

Parameters:

sizeRequested – number of bytes that failed to allocate

Returns:

true if the memory allocation should be retried or false if it should fail

public default void onAllocated(long size)#

Invoked after every memory allocation when debug mode is enabled.

Parameters:

size – number of bytes allocated

public default void onDeallocated(long size)#

Invoked after every memory deallocation when debug mode is enabled.

Parameters:

size – number of bytes deallocated

public default boolean onAllocFailure(
long sizeRequested,
int retryCount
)#

Invoked on a memory allocation failure.

Parameters:
  • sizeRequested – number of bytes that failed to allocate

  • retryCount – number of times this allocation has been retried after failure

Returns:

true if the memory allocation should be retried or false if it should fail

public long[] getAllocThresholds()#

Get the memory thresholds that will trigger onAllocThreshold(long) to be called when one or more of the thresholds is crossed during a memory allocation.

A threshold is crossed when the total memory allocated before the RMM allocate operation is less than a threshold value and the threshold value is less than or equal to the total memory allocated after the RMM memory allocate operation.

Returns:

allocate memory thresholds or null for no thresholds.

public long[] getDeallocThresholds()#

Get the memory thresholds that will trigger onDeallocThreshold(long) to be called when one or more of the thresholds is crossed during a memory deallocation.

A threshold is crossed when the total memory allocated before the RMM deallocate operation is greater than or equal to a threshold value and the threshold value is greater than the total memory allocated after the RMM memory deallocate operation.

Returns:

deallocate memory thresholds or null for no thresholds.

public void onAllocThreshold(long totalAllocSize)#

Invoked after an RMM memory allocate operation when an allocate threshold is crossed.

See getAllocThresholds() for details on allocate threshold crossing.

NOTE: Any exception thrown by this method will cause the corresponding allocation that triggered the threshold callback to be released before the exception is propagated to the application.

Parameters:

totalAllocSize – total amount of memory allocated after the crossing

public void onDeallocThreshold(long totalAllocSize)#

Invoked after an RMM memory deallocation operation when a deallocate threshold is crossed.

See getDeallocThresholds() for details on deallocate threshold crossing.

NOTE: Any exception thrown by this method will be propagated to the application after the resource that triggered the threshold was released.

Parameters:

totalAllocSize – total amount of memory allocated after the crossing