Interface MemoryRequestServer

All Known Implementing Classes:
DefaultMemoryRequestServer

public interface MemoryRequestServer
The MemoryRequestServer is a callback interface to provide a means to request more memory for heap and off-heap WritableMemory resources that are not file-memory-mapped backed resources.

Note: this only works with Java 17.

Author:
Lee Rhodes
  • Method Details

    • request

      default WritableMemory request(WritableMemory currentWritableMemory, long newCapacityBytes)
      Request new WritableMemory with the given newCapacityBytes. The current WritableMemory can be used to determine the byte order of the returned WritableMemory and other properties. A new confined ResourceScope is assigned.
      Parameters:
      currentWritableMemory - the current writableMemory of the client. It must be non-null.
      newCapacityBytes - The capacity being requested. It must be > the capacity of the currentWritableMemory.
      Returns:
      new WritableMemory with the requested capacity.
    • request

      WritableMemory request(WritableMemory currentWritableMemory, long newCapacityBytes, ResourceScope scope)
      Request new WritableMemory with the given newCapacityBytes. The current Writable Memory can be used to determine the byte order of the returned WritableMemory and other properties.
      Parameters:
      currentWritableMemory - the current writableMemory of the client. It must be non-null.
      newCapacityBytes - The capacity being requested. It must be > the capacity of the currentWritableMemory.
      scope - the ResourceScope to be used for the newly allocated memory. It must be non-null. Typically use ResourceScope.newConfinedScope(). Warning: specifying a newSharedScope() is not supported.
      Returns:
      new WritableMemory with the requested capacity.
    • requestClose

      default void requestClose(WritableMemory memToClose)
      Request to close the resource, if applicable.
      Parameters:
      memToClose - the relevant WritableMemory to be considered for closing. It must be non-null.
    • requestClose

      void requestClose(WritableMemory memToClose, WritableMemory newMemory)
      Request to close the resource, if applicable.
      Parameters:
      memToClose - the relevant WritableMemory to be considered for closing. It must be non-null.
      newMemory - the newly allocated WritableMemory. The newMemory reference is returned from the client for the convenience of the system that owns the responsibility of memory allocation. It may be null.