[foreign-memaccess] RFR: 8252770: MemorySegment::allocateNative should honor direct memory limits
    Maurizio Cimadamore 
    mcimadamore at openjdk.java.net
       
    Thu Sep  3 14:23:08 UTC 2020
    
    
  
Currently, `MemorySegment::allocateNative` does not honor the memory limits set for direct buffers
(`-XX:MaxDirectMemorySize` and `-XX:+PageAlignDirectMemory`).This patch rectifies that. The changes are pretty simple,
the main issue was that most of the methods are defined away in the `Bits` class which belongs to the nio package, so
the usual access dance was necessary.
Since segments can already be allocated with an alignment, I slightly tweaked the alignment logic to compute the max
between page size and requested alignment, in case the option for aligning direct memory chunks to page boundaries is
set.
Tweak NativeMemorySegmentImpl to respect direct memory settings
-------------
Commit messages:
 - Tweak NativeMemorySegmentImpl to respect direct memory settings
Changes: https://git.openjdk.java.net/panama-foreign/pull/306/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=306&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8252770
  Stats: 53 lines in 7 files changed: 39 ins; 6 del; 8 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/306.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/306/head:pull/306
PR: https://git.openjdk.java.net/panama-foreign/pull/306
    
    
More information about the panama-dev
mailing list