sun.misc.VM Java Examples
The following examples show how to use
sun.misc.VM.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Finalizer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #2
Source File: Finalizer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #3
Source File: Finalizer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #4
Source File: Finalizer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; ReferenceQueue<Object> q = getQueue(); for (;;) { Finalizer f = (Finalizer)q.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #5
Source File: Finalizer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #6
Source File: Finalizer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #7
Source File: Finalizer.java From hottub with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #8
Source File: Finalizer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #9
Source File: Finalizer.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #10
Source File: PreloadBufferPool.java From journalkeeper with Apache License 2.0 | 6 votes |
/** * 计算可供缓存使用的最大堆外内存。 * * 1. 如果PreloadBufferPool.MaxMemory设置为数值,直接使用设置值。 * 2. 如果PreloadBufferPool.MaxMemory设置为百分比,比如:90%,最大堆外内存 = 物理内存 * 90% - 最大堆内存(由JVM参数-Xmx配置) * 3. 如果PreloadBufferPool.MaxMemory未设置或者设置了非法值,最大堆外内存 = VM.maxDirectMemory() * 90%。 * 其中VM.maxDirectMemory()取值为JVM参数-XX:MaxDirectMemorySize,如果未设置-XX:MaxDirectMemorySize,取值为JVM参数-Xmx。 * * @return 可使用的最大堆外内存大小。 */ private long calcMaxMemorySize() { String mmsString = System.getProperty(MAX_MEMORY_KEY); int pct = Format.getPercentage(mmsString); if (pct > 0 && pct < 100) { long physicalMemorySize = getPhysicalMemorySize(); long reservedHeapMemorySize = Runtime.getRuntime().maxMemory(); if (Long.MAX_VALUE == reservedHeapMemorySize) { logger.warn("Runtime.getRuntime().maxMemory() returns unlimited!"); reservedHeapMemorySize = physicalMemorySize / 2; } // 如果设置了百分比,最大可使用堆外内存= 物理内存 * 百分比 - 最大堆内存 long mms = physicalMemorySize * pct / 100 - reservedHeapMemorySize; if (mms > 0) { return mms; } else { return Math.round(VM.maxDirectMemory() * DEFAULT_CACHE_RATIO); } } return Format.parseSize(System.getProperty(MAX_MEMORY_KEY), Math.round(VM.maxDirectMemory() * DEFAULT_CACHE_RATIO)); }
Example #11
Source File: Finalizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #12
Source File: Finalizer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #13
Source File: Finalizer.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #14
Source File: Finalizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #15
Source File: Finalizer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #16
Source File: PreloadBufferPool.java From joyqueue with Apache License 2.0 | 6 votes |
/** * 计算可供缓存使用的最大堆外内存。 * * 1. 如果PreloadBufferPool.MaxMemory设置为数值,直接使用设置值。 * 2. 如果PreloadBufferPool.MaxMemory设置为百分比,比如:90%,最大堆外内存 = 物理内存 * 90% - 最大堆内存(由JVM参数-Xmx配置) * 3. 如果PreloadBufferPool.MaxMemory未设置或者设置了非法值,最大堆外内存 = VM.maxDirectMemory() * 90%。 * 其中VM.maxDirectMemory()取值为JVM参数-XX:MaxDirectMemorySize,如果未设置-XX:MaxDirectMemorySize,取值为JVM参数-Xmx。 * * @return 可使用的最大堆外内存大小。 */ private long getMaxMemorySize() { String mmsString = System.getProperty(MAX_MEMORY_KEY); int pct = Format.getPercentage(mmsString); if (pct > 0 && pct < 100) { long physicalMemorySize = getPhysicalMemorySize(); long reservedHeapMemorySize = Runtime.getRuntime().maxMemory(); if (Long.MAX_VALUE == reservedHeapMemorySize) { logger.warn("Runtime.getRuntime().maxMemory() returns unlimited!"); reservedHeapMemorySize = physicalMemorySize / 2; } // 如果设置了百分比,最大可使用堆外内存= 物理内存 * 百分比 - 最大堆内存 long mms = physicalMemorySize * pct / 100 - reservedHeapMemorySize; // 最大堆外内存 * CACHE_RATIO,这是使用堆外内存的上限,超过这个上限会导致频繁的FullGC long mdm = Math.round(VM.maxDirectMemory() * CACHE_RATIO); if (mms > 0 && mms < mdm) { return mms; } else { return mdm; } } return Format.parseSize(System.getProperty(MAX_MEMORY_KEY), Math.round(VM.maxDirectMemory() * CACHE_RATIO)); }
Example #17
Source File: Finalizer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #18
Source File: Finalizer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #19
Source File: Finalizer.java From JDKSourceCode1.8 with MIT License | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #20
Source File: Finalizer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { // in case of recursive call to run() if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #21
Source File: Finalizer.java From Java8CN with Apache License 2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #22
Source File: Finalizer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
static void runAllFinalizers() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f; synchronized (lock) { f = unfinalized; if (f == null) break; unfinalized = f.next; } f.runFinalizer(jla); }}}); }
Example #23
Source File: Finalizer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
static void runFinalization() { if (!VM.isBooted()) { return; } forkSecondaryFinalizer(new Runnable() { private volatile boolean running; public void run() { if (running) return; final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); running = true; for (;;) { Finalizer f = (Finalizer)queue.poll(); if (f == null) break; f.runFinalizer(jla); } } }); }
Example #24
Source File: Proxy.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void checkProxyAccess(Class<?> caller, ClassLoader loader, Class<?>... interfaces) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { ClassLoader ccl = caller.getClassLoader(); if (VM.isSystemDomainLoader(loader) && !VM.isSystemDomainLoader(ccl)) { sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); } ReflectUtil.checkProxyPackageAccess(ccl, interfaces); } }
Example #25
Source File: ClassLoader.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private boolean checkName(String name) { if ((name == null) || (name.length() == 0)) return true; if ((name.indexOf('/') != -1) || (!VM.allowArraySyntax() && (name.charAt(0) == '['))) return false; return true; }
Example #26
Source File: Bits.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void reserveMemory(long size, int cap) { synchronized (Bits.class) { if (!memoryLimitSet && VM.isBooted()) { maxMemory = VM.maxDirectMemory(); memoryLimitSet = true; } // -XX:MaxDirectMemorySize limits the total capacity rather than the // actual memory usage, which will differ when buffers are page // aligned. if (cap <= maxMemory - totalCapacity) { reservedMemory += size; totalCapacity += cap; count++; return; } } System.gc(); try { Thread.sleep(100); } catch (InterruptedException x) { // Restore interrupt status Thread.currentThread().interrupt(); } synchronized (Bits.class) { if (totalCapacity + cap > maxMemory) throw new OutOfMemoryError("Direct buffer memory"); reservedMemory += size; totalCapacity += cap; count++; } }
Example #27
Source File: Proxy.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void checkProxyAccess(Class<?> caller, ClassLoader loader, Class<?>... interfaces) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { ClassLoader ccl = caller.getClassLoader(); if (VM.isSystemDomainLoader(loader) && !VM.isSystemDomainLoader(ccl)) { sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); } ReflectUtil.checkProxyPackageAccess(ccl, interfaces); } }
Example #28
Source File: ClassLoader.java From JDKSourceCode1.8 with MIT License | 5 votes |
private boolean checkName(String name) { if ((name == null) || (name.length() == 0)) return true; if ((name.indexOf('/') != -1) || (!VM.allowArraySyntax() && (name.charAt(0) == '['))) return false; return true; }
Example #29
Source File: ClassLoader.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private boolean checkName(String name) { if ((name == null) || (name.length() == 0)) return true; if ((name.indexOf('/') != -1) || (!VM.allowArraySyntax() && (name.charAt(0) == '['))) return false; return true; }
Example #30
Source File: Proxy.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkProxyAccess(Class<?> caller, ClassLoader loader, Class<?>... interfaces) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { ClassLoader ccl = caller.getClassLoader(); if (VM.isSystemDomainLoader(loader) && !VM.isSystemDomainLoader(ccl)) { sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); } ReflectUtil.checkProxyPackageAccess(ccl, interfaces); } }