Skip to content
Permalink
Browse files

8237348: Javadoc of MemorySegment::allocateNative should state that m…

…emory is zero-initialized8237348: Javadoc of MemorySegment::allocateNative should state that memory is zero-initialized

Reviewed-by: chegar, jlaskey
  • Loading branch information
mcimadamore committed Jan 16, 2020
1 parent 5903e20 commit af5ff9aeeeec12d8e84c00cc5133a55051728bb2
Showing with 9 additions and 12 deletions.
  1. +9 −12 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemorySegment.java
@@ -348,10 +348,9 @@ static MemorySegment ofArray(double[] arr) {
allocateNative(layout.bytesSize(), layout.bytesAlignment());
* }</pre></blockquote>
*
* @implNote The initialization state of the contents of the block of off-heap memory associated with the returned native memory
* segment is unspecified and should not be relied upon. Moreover, a client is responsible to call the {@link MemorySegment#close()}
* on a native memory segment, to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so
* will result in off-heap memory leaks.
* @implNote The block of off-heap memory associated with the returned native memory segment is initialized to zero.
* Moreover, a client is responsible to call the {@link MemorySegment#close()} on a native memory segment,
* to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so will result in off-heap memory leaks.
*
* @param layout the layout of the off-heap memory block backing the native memory segment.
* @return a new native memory segment.
@@ -369,10 +368,9 @@ static MemorySegment allocateNative(MemoryLayout layout) {
allocateNative(bytesSize, 1);
* }</pre></blockquote>
*
* @implNote The initialization state of the contents of the block of off-heap memory associated with the returned native memory
* segment is unspecified and should not be relied upon. Moreover, a client is responsible to call the {@link MemorySegment#close()}
* on a native memory segment, to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so
* will result in off-heap memory leaks.
* @implNote The block of off-heap memory associated with the returned native memory segment is initialized to zero.
* Moreover, a client is responsible to call the {@link MemorySegment#close()} on a native memory segment,
* to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so will result in off-heap memory leaks.
*
* @param bytesSize the size (in bytes) of the off-heap memory block backing the native memory segment.
* @return a new native memory segment.
@@ -404,10 +402,9 @@ static MemorySegment mapFromPath(Path path, long bytesSize, FileChannel.MapMode
* Creates a new native memory segment that models a newly allocated block of off-heap memory with given size and
* alignment constraint (in bytes).
*
* @implNote The initialization state of the contents of the block of off-heap memory associated with the returned native memory
* segment is unspecified and should not be relied upon. Moreover, a client is responsible to call the {@link MemorySegment#close()}
* on a native memory segment, to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so
* will result in off-heap memory leaks.
* @implNote The block of off-heap memory associated with the returned native memory segment is initialized to zero.
* Moreover, a client is responsible to call the {@link MemorySegment#close()} on a native memory segment,
* to make sure the backing off-heap memory block is deallocated accordingly. Failure to do so will result in off-heap memory leaks.
*
* @param bytesSize the size (in bytes) of the off-heap memory block backing the native memory segment.
* @param alignmentBytes the alignment constraint (in bytes) of the off-heap memory block backing the native memory segment.

0 comments on commit af5ff9a

Please sign in to comment.