How to see JIT-compiled code in JVM?

General usage As explained by other answers, you can run with the following JVM options: -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly Filter on a specific method You can also filter on a specific method with the following syntax: -XX:+UnlockDiagnosticVMOptions -XX:CompileCommand=print,*MyClass.myMethod Notes: you might need to put the second argument within quotes depending on OS etc. if the method gets … Read more

Integers caching in Java [duplicate]

I want to understand purposes of this optimization. In what cases performance is increased, etc. Reference to some research of this problem will be great. The purpose is mainly to save memory, which also leads to faster code due to better cache efficiency. Basically, the Integer class keeps a cache of Integer instances in the … Read more

Maximum Java heap size of a 32-bit JVM on a 64-bit OS

You can ask the Java Runtime: public class MaxMemory { public static void main(String[] args) { Runtime rt = Runtime.getRuntime(); long totalMem = rt.totalMemory(); long maxMem = rt.maxMemory(); long freeMem = rt.freeMemory(); double megs = 1048576.0; System.out.println (“Total Memory: ” + totalMem + ” (” + (totalMem/megs) + ” MiB)”); System.out.println (“Max Memory: ” + … Read more

How do I set the proxy to be used by the JVM

From the Java documentation (not the javadoc API): http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html Set the JVM flags http.proxyHost and http.proxyPort when starting your JVM on the command line. This is usually done in a shell script (in Unix) or bat file (in Windows). Here’s the example with the Unix shell script: JAVA_FLAGS=-Dhttp.proxyHost=10.0.0.100 -Dhttp.proxyPort=8800 java ${JAVA_FLAGS} … When using containers … Read more

Java using much more memory than heap size (or size correctly Docker memory limit)

Virtual memory used by a Java process extends far beyond just Java Heap. You know, JVM includes many subsytems: Garbage Collector, Class Loading, JIT compilers etc., and all these subsystems require certain amount of RAM to function. JVM is not the only consumer of RAM. Native libraries (including standard Java Class Library) may also allocate … Read more