jvm-hotspot

OpenJDK vs Java HotspotVM

有些话、适合烂在心里 提交于 2019-12-03 10:41:57
Are OpenJDK VM and Oracle Hotspot VM still two different JVMs? I can't seem to find any somewhat official documentation on anything about OpenJDK VM. Even in OpenJDK homepage there is an HotSpot Group which develops HotSpot VM. The HotSpot group is comprised of developers involved in the design, implementation, and maintanence of the HotSpot virtual machine However if I check java -version on my Windows machine it prints out Java HotSpot(TM) 64-Bit Server VM But on my Ubuntu VPS OpenJDK 64-Bit Server VM If those are two different VMs what are the main differences between them? Do they have

How is ArrayOutOfBoundsException possible in String.valueOf(int)?

你离开我真会死。 提交于 2019-12-03 10:41:05
问题 Why does this code sometimes produce ArrayOutOfBoundsException? How is that even possible for String.valueOf(int) ? public static String ipToString(ByteString bs) { if (bs == null || bs.isEmpty()) { return null; } else { StringBuilder sb = new StringBuilder(); boolean started = false; for (Byte byt : bs) { if (started) { sb.append("."); } sb.append(String.valueOf(byt & 0xFF)); started = true; } return sb.toString(); } } java.lang.ArrayIndexOutOfBoundsException: -81914 at java.lang.Integer

What are the differences in JIT between Java and .Net

蹲街弑〆低调 提交于 2019-12-03 10:37:25
I know Microsoft .NET uses the CLR as a JIT compiler while Java has the Hotspot. What Are the differences between them? They are very different beasts. As people pointed out, the CLR compiles to machine code before it executes a piece of MSIL. This allows it in addition to the typical dead-code elimination and inlining off privates optimizations to take advantage of the particular CPU architecture of the target machine (though I'm not sure whether it does it). This also incurs a hit for each class (though the compiler is fairly fast and many platform libraries are just a thin layer over the

Useless test instruction?

独自空忆成欢 提交于 2019-12-03 10:34:32
问题 I got the below assembly list as result for JIT compilation for my java program. mov 0x14(%rsp),%r10d inc %r10d mov 0x1c(%rsp),%r8d inc %r8d test %eax,(%r11) ; <--- this instruction mov (%rsp),%r9 mov 0x40(%rsp),%r14d mov 0x18(%rsp),%r11d mov %ebp,%r13d mov 0x8(%rsp),%rbx mov 0x20(%rsp),%rbp mov 0x10(%rsp),%ecx mov 0x28(%rsp),%rax movzbl 0x18(%r9),%edi movslq %r8d,%rsi cmp 0x30(%rsp),%rsi jge 0x00007fd3d27c4f17 My understanding the test instruction is useless here because the main idea of the

Java8 metaspace & heap usage

半世苍凉 提交于 2019-12-03 10:16:51
I have this code to generate class dynamically and load it import javassist.CannotCompileException; import javassist.ClassPool; public class PermGenLeak { private static final String PACKAGE_NAME = "com.jigarjoshi.permgenleak."; public static void main(String[] args) throws CannotCompileException, InterruptedException { for (int i = 0; i < Integer.MAX_VALUE; i++) { ClassPool pool = ClassPool.getDefault(); pool.makeClass(PACKAGE_NAME + i).toClass(); Thread.sleep(3); } } } I launched this class against Java 7 (jdk1.7.0_60) and as expected it filled up PermGenSpace and heap remained unused image

Default for XX:MaxDirectMemorySize

此生再无相见时 提交于 2019-12-03 09:30:51
What is the default value for XX:MaxDirectMemorySize? John Gardner From http://www.docjar.com/html/api/sun/misc/VM.java.html i see: 163 // A user-settable upper limit on the maximum amount of allocatable direct 164 // buffer memory. This value may be changed during VM initialization if 165 // "java" is launched with "-XX:MaxDirectMemorySize=<size>". 166 // 167 // The initial value of this field is arbitrary; during JRE initialization 168 // it will be reset to the value specified on the command line, if any, 169 // otherwise to Runtime.getRuntime.maxDirectMemory(). 170 // 171 private static

Hotspot7 hsdis PrintAssembly Intel Syntax

允我心安 提交于 2019-12-03 08:56:07
问题 It annoys me every time I use -XX:+PrintAssembly with Hotspot and have to read the horrible AT&T syntax. Is there a way to tell it to use the Intel syntax? 回答1: All you need is to parse some options onto the dis-asm.h and binutils code For intel Asm (which I also prefer) just add the following -XX:PrintAssemblyOptions=intel If you need to combine options do it with commas like so -XX:PrintAssemblyOptions=intel,hsdis-help Anything not recognised as a hsdis option will be fed to the

How can I write code to hint to the JVM to use vector operations?

纵然是瞬间 提交于 2019-12-03 08:44:43
问题 Somewhat related question, and a year old: Do any JVM's JIT compilers generate code that uses vectorized floating point instructions? Preface: I am trying to do this in pure java (no JNI to C++, no GPGPU work, etc...). I have profiled and the bulk of the processing time is coming from the math operations in this method (which is probably 95% floating point math and 5% integer math). I've already reduced all Math.xxx() calls to an approximation that's good enough so most of the math is now

Why does Java , running in -server mode, say that the version is “mixed-mode”?

喜欢而已 提交于 2019-12-03 07:45:54
问题 Why does Java , running in -server mode, say that the version is "mixed-mode" ? When I see that, does it mean that the JVM didn't truly load in pure server mode? 回答1: server mode does not mean "not mixed". Those are different settings. Mixed does mean that the JVM will mix compiled and interpreted code. You could optionally switch to fully interpreted mode with the switch -Xint (usually you don't want to do this). Server mode means that the hot-spot-compiler will run with server-settings. The

What causes the JVM to do a major garbage collection?

眉间皱痕 提交于 2019-12-03 07:05:25
I have a Java app which shows different GC behaviors in different environments. In one environment, the heap usage graph is a slow sawtooth with major GCs every 10 hours or so, only when the heap is >90% full. In another environment, the JVM does major GCs every hour on the dot (the heap is normally between 10% and 30% at these times). My question is, what are the factors which cause the JVM to decide to do a major GC? Obviously it collects when the heap is nearly full, but there is some other cause at play which I am guessing is related to an hourly scheduled task within my app (although