How to Increase Heap Size in Java Virtual Machine?
Last Updated :
13 Jan, 2023
There are two types of memory stack memory and heap memory. All the dynamic allocations go into heap memory and the rest of the static allocations and variables allocations go into stack memory. Whenever a java program is executed in the java virtual machine it uses the heap memory to manage the data. Task Engine runs on JVM (Java Virtual Machine). Hierarchy is pictorially shown below.

So now coming onto heap memory, the heap is a location in memory used by the Java Virtual Machine (JVM). The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated. The heap is created on a virtual machine start-up. Heap storage for objects is reclaimed by an automatic storage management system (known as a garbage collector); objects are never explicitly reallocated. The Java Virtual Machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementer's system requirements. The heap may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger heap becomes unnecessary. The memory for the heap does not need to be contiguous.
A Java Virtual Machine implementation may provide the programmer or the user control over the initial size of the heap, as well as, if the heap can be dynamically expanded or contracted, control over the maximum and minimum heap size. The following exceptional condition is associated with the heap whenever a computation requires more heap than can be made available by the automatic storage management system, the Java Virtual Machine throws an OutOfMemoryError.
By default, the JVM heap size is 1GB, which is usually enough to accommodate the data used by Task Engine. However, larger heap size may be required under some circumstances, for example, when the average size of the parameters in a task is very large. Under these circumstances, the following log item is recorded in Task Engine log files. If this log item appears regularly, you need to increase the heap size.
Now the question arises of how to increase the heap size of memory. So a common solution to it Now in order to change/increase the JVM heap size is made possible by using command-line options.
-Xms : To set an initial java heap size
-Xmx : To set maximum java heap size
-Xss : To set the Java thread stack size
-Xmn : For setting the size of young generation, rest of the space goes for old generation
Procedure: To increase the Application Server JVM heap size
- Log in to the Application Server Administration Server.
- Navigate to the JVM options.
- Edit the -Xmx256m option.
- This option sets the JVM heap size.
- Set the -Xmx256m option to a higher value, such as Xmx1024m.
- Save the new setting.
Note:
The process to change the heap size of the Web Server is the same you just need to log in in Web Server Administration Server. After that process is the same. It is good practice for big production projects to set the minimum -Xms and maximum -Xmx heap sizes to the same value. For efficient garbage collection, the -Xmn value should be lower than the -Xmx value. Heap size does not determine the amount of memory your process uses.
Similar Reads
Java Virtual Machine (JVM) Stack Area The Java Virtual Machine is responsible for running Java applications, and it manages various memory areas, one of which is the Stack Area. In this article, we are going to discuss about JVM Stack Area in depth.JVM Stack AreaIn Java, each thread has its own stack called the Run-Time Stack, created w
5 min read
How to Increase Docker-Machine Memory Mac Docker machine is a tool that is used popularly for managing the docker engine on several types of virtual hosts, it can also be used to run in the old versions of Windows as well as macOS. the docker did not run on the macOS Windows operating system natively, so another machine was created so that
6 min read
How to Increase RAM in macOS? Lack of memory or RAM which refers to random access memory can be an extremely irritating affair. This is particularly the case if you work with resource-demanding apps or you have several concurrent processes on your macOS device. While some models of Windows computers allow for RAM upgrades, the l
6 min read
How to Install VisualVM in Linux When operating on a Java Virtual Machine, the sophisticated tool VisualVM offers a visual interface for viewing in-depth details about local and remote Java applications (JVM). To see the program within the JVM, it makes use of and integrates some of the command-line tools that the JDK offers; this
3 min read
Vector setSize() method in Java with Example The Java.util.Vector.setSize() is a method of Vector class that is used to set the new size of the vector. If the new size of the vector is greater than the current size then null elements are added to the vector is new size is less than the current size then all higher-order elements are deleted. T
3 min read