Skip to content
  • There are no suggestions because the search field is empty.

How-To : Adjust Default JVM Heap Memory Size

Overview

When running HighByte Intelligence Hub, the Java Virtual Machine (JVM) allocates a portion of your system's memory, called the heap, to store objects and data created during runtime. The heap size determines how much memory is available for processing data flows, managing connections, and performing other critical operations.

Properly configuring the heap size ensures efficient memory usage, enhances application stability, and optimizes performance. This article explains how to adjust the heap size in the start-windows.bat file for Windows installations of HighByte Intelligence Hub.

Default Heap Size Behavior

By default, the JVM dynamically determines the heap size based on your system’s physical memory:

  • The initial heap size (-Xms) is set to 1/64th of the system's memory.
  • The maximum heap size (-Xmx) is set to 1/4th of the system's memory.

    For example, on a system with 64GB of RAM, the default initial heap size would be 1GB, and the maximum heap size would be 16GB.

Why Adjust Heap Size?

Adjusting the JVM heap size helps optimize HighByte Intelligence Hub for your specific workload and environment by providing better performance, stability, and resource utilization.

  1. Improve Stability Under Load: For memory-intensive applications, setting an appropriate heap size ensures stable performance during high-demand operations. This prevents unexpected crashes or delays when processing large amounts of data.
  2. Achieve Predictable Performance: Fixed heap sizes provide consistent memory allocation, especially in environments with high resource usage or constraints.
  3. Reduce Runtime Overhead: Pre-allocating memory avoids dynamic resizing during operations, which can reduce CPU load and latency.

  4.  Optimize Performance in Dedicated Environments:
    In environments running only HighByte Intelligence Hub, adjusting the heap size maximizes available memory usage.
  5.  Handle Resource-Intensive Use Cases:
    For scenarios with high data throughput, complex data flows, or many concurrent connections, increasing the heap size ensures the application can efficiently process workloads without encountering memory bottlenecks that result in a crash. 

How to Adjust the Heap Size 

  1. Locate the start-windows.bat File:
    • Navigate to the directory where HighByte Intelligence Hub is installed.
    • Open the start-windows.bat In a text editor
  2. Modify the JVM Options:
    • By default, the file will contain
      pushd .
      cd /D "%~dp0"
      java -cp "intelligencehub-runtime.jar;lib/*" com.highbyte.intelligencehub.runtime.Main start
      pop

       

    • Update the java command to include -Xms and -Xmx options
      java -Xms20g -Xmx20g -cp "intelligencehub-runtime.jar;lib/*" com.highbyte.intelligencehub.runtime.Main start

       

      • -Xms20g: Sets the initial heap size to 20GB.
      • -Xmx20g: Sets the maximum heap size to 20GB.
  3. Adjust the Memory Size:
    • Replace 20g with your desired heap size:
      • For 16GB: -Xms16g -Xmx16g
      • For 24GB: -Xms24g -Xmx24g
    • Ensure the Heap Size Matches the available system memory, leaving enough resources for the OS and other applications
  4. Save and Restart HighByte
    • Save the updated start-windows.bat file.
    • Restart HighByte Intelligence Hub for the changes to take effect


How to determine Heap Size Configuration

  • Monitor Memory Usage: Use tools like JVisualVM, Java Mission Control, or external system monitors to determine if memory allocation is sufficient.
  •  Match Workload Requirements: Set the heap size based on the expected workload. 
  •  Avoid Over-Allocation: Ensure the total memory allocated (-Xmx) does not exceed the system’s physical memory minus what’s needed for the operating system and other applications. 

  • Adjust Incrementally : Start with a smaller heap size and monitor performance before increasing further.

FAQs

What happens if I don’t set -Xms?

If you omit the -Xms option, the JVM dynamically grows the heap from a small default size (typically 1/64th of the system memory). This can cause performance overhead due to resizing.

Should I always set -Xms equal to -Xmx?

For performance-critical applications or systems with predictable memory usage, setting -Xms equal to -Xmx is recommended. For variable workloads, letting the JVM manage the initial heap size is acceptable.

What is the maximum heap size I can set?

The maximum heap size depends on your system’s physical memory. On 64-bit systems, it can be set as high as available memory allows, minus resources required for the OS and other applications. In containerized environments, ensure the maximum heap size fits within the container’s memory limits.

Related Articles