# Interface MemorySegmentRequest

All Known Implementing Classes:
  `MemorySegmentRequest.Default, MemorySegmentRequestExample`

public interface MemorySegmentRequest
This is a callback interface to provide a means to request a new MemorySegment of a specified size.

Author:
  Lee Rhodes

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static class`
`MemorySegmentRequest.Default`
A convenience class that implements a default implementation.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final MemorySegmentRequest.Default`
`DEFAULT`
Create Default as static member.

## Method Summary

Modifier and Type
Method
Description
`default MemorySegment`
`request(long newByteSize)`
Request a new heap MemorySegment with the given newByteSize.
`default void`
`requestClose(MemorySegment prevSeg)`
Request to close the given MemorySegment.

## Field Details

### DEFAULT

static final MemorySegmentRequest.Default DEFAULT
Create Default as static member.

## Method Details

### request

default MemorySegment request(long newByteSize)
Request a new heap MemorySegment with the given newByteSize. Because we do not have a reference to an Arena, the default here is to allocate a new MemorySegment on the heap. It is up to the user to override this as appropriate.

Parameters:
  `newByteSize` - The new byteSize being requested.
Returns:
  new MemorySegment with the requested byteSize.

### requestClose

default void requestClose(MemorySegment prevSeg)
Request to close the given MemorySegment. Because we do not have a reference to an Arena, the default here is to do nothing. It is up to the user to override this as appropriate.

Parameters:
  `prevSeg` - the previous MemorySegment to be closed.