Posts

Showing posts from October, 2010

how to get total Heap Size in JVM

Runtime runtime = Runtime.getRuntime(); System.out.println("Total Heap Size of JVM"+runtime.totalMemory());

Increase JVM Heap Size for better performance.

Setting/Increase JVM heap size It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options. Following are few options available to change Heap Size. 1 -Xms< size >        set initial Java heap size 2 -Xmx< size >        set maximum Java heap size 3 -Xss< size >        set java thread stack size For example, you can set minimum heap to 64 MB and maximum heap 256 MB for a Java program HelloWorld. 1 java -Xms64m -Xmx256m HelloWorld

How to examine the amount of free memory in java

Runtime runtime = Runtime.getRuntime(); System.out.println ("Free memory : " - + runtime.freeMemory() );

ArrayList or vector

ArrayList: Its not thread safe-- its unsynchronized. ArrayList can be traversed with Iterator Interface. So Its faster compared to Vector. Vector: It is thread safe and synchronized. Vector can be traversed with  Enumeration-- Interface