< prev index next >

src/share/classes/java/nio/Bits.java

Print this page




 598     static int pageSize() {
 599         if (pageSize == -1)
 600             pageSize = unsafe().pageSize();
 601         return pageSize;
 602     }
 603 
 604     static int pageCount(long size) {
 605         return (int)(size + (long)pageSize() - 1L) / pageSize();
 606     }
 607 
 608     private static boolean unaligned;
 609     private static boolean unalignedKnown = false;
 610 
 611     static boolean unaligned() {
 612         if (unalignedKnown)
 613             return unaligned;
 614         String arch = AccessController.doPrivileged(
 615             new sun.security.action.GetPropertyAction("os.arch"));
 616         unaligned = arch.equals("i386") || arch.equals("x86")
 617             || arch.equals("amd64") || arch.equals("x86_64")
 618             || arch.equals("ppc64") || arch.equals("ppc64le");

 619         unalignedKnown = true;
 620         return unaligned;
 621     }
 622 
 623 
 624     // -- Direct memory management --
 625 
 626     // A user-settable upper limit on the maximum amount of allocatable
 627     // direct buffer memory.  This value may be changed during VM
 628     // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
 629     private static volatile long maxMemory = VM.maxDirectMemory();
 630     private static final AtomicLong reservedMemory = new AtomicLong();
 631     private static final AtomicLong totalCapacity = new AtomicLong();
 632     private static final AtomicLong count = new AtomicLong();
 633     private static volatile boolean memoryLimitSet = false;
 634     // max. number of sleeps during try-reserving with exponentially
 635     // increasing delay before throwing OutOfMemoryError:
 636     // 1, 2, 4, 8, 16, 32, 64, 128, 256 (total 511 ms ~ 0.5 s)
 637     // which means that OOME will be thrown after 0.5 s of trying
 638     private static final int MAX_SLEEPS = 9;




 598     static int pageSize() {
 599         if (pageSize == -1)
 600             pageSize = unsafe().pageSize();
 601         return pageSize;
 602     }
 603 
 604     static int pageCount(long size) {
 605         return (int)(size + (long)pageSize() - 1L) / pageSize();
 606     }
 607 
 608     private static boolean unaligned;
 609     private static boolean unalignedKnown = false;
 610 
 611     static boolean unaligned() {
 612         if (unalignedKnown)
 613             return unaligned;
 614         String arch = AccessController.doPrivileged(
 615             new sun.security.action.GetPropertyAction("os.arch"));
 616         unaligned = arch.equals("i386") || arch.equals("x86")
 617             || arch.equals("amd64") || arch.equals("x86_64")
 618             || arch.equals("ppc64") || arch.equals("ppc64le")
 619             || arch.equals("aarch64");
 620         unalignedKnown = true;
 621         return unaligned;
 622     }
 623 
 624 
 625     // -- Direct memory management --
 626 
 627     // A user-settable upper limit on the maximum amount of allocatable
 628     // direct buffer memory.  This value may be changed during VM
 629     // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
 630     private static volatile long maxMemory = VM.maxDirectMemory();
 631     private static final AtomicLong reservedMemory = new AtomicLong();
 632     private static final AtomicLong totalCapacity = new AtomicLong();
 633     private static final AtomicLong count = new AtomicLong();
 634     private static volatile boolean memoryLimitSet = false;
 635     // max. number of sleeps during try-reserving with exponentially
 636     // increasing delay before throwing OutOfMemoryError:
 637     // 1, 2, 4, 8, 16, 32, 64, 128, 256 (total 511 ms ~ 0.5 s)
 638     // which means that OOME will be thrown after 0.5 s of trying
 639     private static final int MAX_SLEEPS = 9;


< prev index next >