# Uses of Interface
jdk.incubator.foreign.ResourceScope

Packages that use ResourceScope
Package
Description
jdk.incubator.foreign
Classes to support low-level and efficient foreign memory/function access, directly from Java.

## Uses of ResourceScope in jdk.incubator.foreign

Methods in jdk.incubator.foreign that return ResourceScope
Modifier and Type
Method
Description
`static ResourceScope`
ResourceScope.`globalScope()`
Returns an implicit scope which is assumed to be always alive.
`static ResourceScope`
ResourceScope.`newConfinedScope()`
Create a new confined scope.
`static ResourceScope`
ResourceScope.`newConfinedScope(Cleaner cleaner)`
Create a new confined scope managed by a `Cleaner`.
`static ResourceScope`
ResourceScope.`newImplicitScope()`
Create a new implicit scope.
`static ResourceScope`
ResourceScope.`newSharedScope()`
Create a new shared scope.
`static ResourceScope`
ResourceScope.`newSharedScope(Cleaner cleaner)`
Create a new shared scope managed by a `Cleaner`.
`ResourceScope`
CLinker.VaList.`scope()`
Returns the resource scope associated with this instance.
`ResourceScope`
MemoryAddress.`scope()`
Returns the resource scope associated with this memory address.
`ResourceScope`
MemorySegment.`scope()`
Returns the resource scope associated with this memory segment.
`ResourceScope`
ResourceScope.Handle.`scope()`
Returns the resource scope associated with this handle.
Methods in jdk.incubator.foreign with parameters of type ResourceScope
Modifier and Type
Method
Description
`static MemorySegment`
MemorySegment.`allocateNative(long bytesSize, long alignmentBytes, ResourceScope scope)`
Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given size (in bytes), alignment constraint (in bytes) and resource scope.
`static MemorySegment`
MemorySegment.`allocateNative(long bytesSize, ResourceScope scope)`
Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given size (in bytes) and resource scope.
`static MemorySegment`
MemorySegment.`allocateNative(MemoryLayout layout, ResourceScope scope)`
Creates a new confined native memory segment that models a newly allocated block of off-heap memory with given layout and resource scope.
`static SegmentAllocator`
SegmentAllocator.`arenaAllocator(long size, ResourceScope scope)`
Returns a native arena-based allocator which allocates a single memory segment, of given size (using malloc), and then responds to allocation request by returning different slices of that same segment (until no further allocation is possible).
`static SegmentAllocator`
SegmentAllocator.`arenaAllocator(ResourceScope scope)`
Returns a native unbounded arena-based allocator.
`MemorySegment`
MemoryAddress.`asSegment(long bytesSize, Runnable cleanupAction, ResourceScope scope)`
Returns a new native memory segment with given size and resource scope (replacing the scope already associated with this address), and whose base address is this address.
`MemorySegment`
MemoryAddress.`asSegment(long bytesSize, ResourceScope scope)`
Returns a new native memory segment with given size and resource scope (replacing the scope already associated with this address), and whose base address is this address.
`static CLinker.VaList`
CLinker.VaList.`make(Consumer<CLinker.VaList.Builder> actions, ResourceScope scope)`
Constructs a new `VaList` using a builder (see `CLinker.VaList.Builder`), associated with a given resource scope.
`static MemorySegment`
MemorySegment.`mapFile(Path path, long bytesOffset, long bytesSize, FileChannel.MapMode mapMode, ResourceScope scope)`
Creates a new mapped memory segment that models a memory-mapped region of a file from a given path.
`static CLinker.VaList`
CLinker.VaList.`ofAddress(MemoryAddress address, ResourceScope scope)`
Constructs a new `VaList` instance out of a memory address pointing to an existing C `va_list`, with given resource scope.
`static SegmentAllocator`
SegmentAllocator.`ofScope(ResourceScope scope)`
Returns a native allocator which responds to allocation requests by allocating new segments bound by the given resource scope, using the `MemorySegment.allocateNative(long, long, ResourceScope)` factory.
`static MemorySegment`
CLinker.`toCString(String str, ResourceScope scope)`
Converts a Java string into a UTF-8 encoded, null-terminated C string, storing the result into a native memory segment associated with the provided resource scope.
`MemoryAddress`
CLinker.`upcallStub(MethodHandle target, FunctionDescriptor function, ResourceScope scope)`
Allocates a native stub with given scope which can be passed to other foreign functions (as a function pointer); calling such a function pointer from native code will result in the execution of the provided method handle.
`MemorySegment`
CLinker.VaList.`vargAsSegment(MemoryLayout layout, ResourceScope scope)`
Reads the next value as a `MemorySegment`, and advances this va list's position.