Why would you ever implement finalize()?

You could use it as a backstop for an object holding an external resource (socket, file, etc). Implement a close() method and document that it needs to be called. Implement finalize() to do the close() processing if you detect it hasn’t been done. Maybe with something dumped to stderr to point out that you’re cleaning … Read more

PermGen elimination in JDK 8

Reasons of ignoring these argument is permanent generation has been removed in HotSpot for JDK8 because of following drawbacks Fixed size at startup – difficult to tune. Internal Hotspot types were Java objects : Could move with full GC, opaque, not strongly typed and hard to debug, needed meta-metadata. Simplify full collections : Special iterators … Read more

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

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