Interface MemorySegmentPool

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
FixedSizeNativeMemorySegmentPool, NativeMemorySegmentPool

public interface MemorySegmentPool extends AutoCloseable
Common interface for native memory segment pooling strategies.
Since:
1.2
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Summary

    Modifier and Type
    Method
    Description
    acquire(long sizeBytes)
    Acquires a memory segment from the pool.
    void
     
    int
    Gets the number of segments currently in the pool.
    void
    Returns a memory segment to the pool for reuse.
  • Method Details

    • acquire

      MemorySegment acquire(long sizeBytes)
      Acquires a memory segment from the pool.
      Parameters:
      sizeBytes - requested size in bytes
      Returns:
      a memory segment of at least the requested size
    • release

      void release(MemorySegment segment)
      Returns a memory segment to the pool for reuse.
      Parameters:
      segment - the segment to return
    • getPoolSize

      int getPoolSize()
      Gets the number of segments currently in the pool.
      Returns:
      pool size
    • close

      void close()
      Specified by:
      close in interface AutoCloseable