- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change/increase the heap size of the Java Virtual Machine in Java?
A Java program can execute in the Java Virtual Machine (JVM) uses the heap memory to manage the data. If our Java program requires more memory, there is a possibility that the Java Virtual Machine(JVM) will begin to throw OutOfMemoryError instances when attempting to instantiate an object in Java.
To Change/increase the JVM Heap Size
In Java, It is possible to increase the heap size allocated by the JVM using command line options
- -Xms - Set an initial Java heap size
- -Xmx - Set the maximum Java heap size
- -Xss - Set the Java thread stack size
Example
public class HeapSizeTest { public static void main(String[]args){ // To get the JVM Heap Size long heapSize = Runtime.getRuntime().totalMemory(); // To print the JVM Heap Size System.out.println("Heap Size: " + heapSize); } }
Output
Heap Size: 16252928
Advertisements