# Configure JVM maximum heap size

The grammar component in the proofreader application runs on a Java Virtual Machine (JVM). By default, the JVM uses 2048 MB of memory, but this may need adjustment based on the language installation and system resources.

### When to adjust the JVM memory

#### Understanding the default setting

The installation comes with a default maximum heap size of 2048 MB (2 GB).

This setting affects only the grammar component. It doesn’t affect spell checking or AI-driven checks. When the JVM doesn’t have enough memory, the garbage collector works harder to free up resources, which consumes more CPU and degrades performance.

#### Quick assessment based on languages

Use this quick reference to determine if the memory allocation needs adjustment:

* **1 language installed:** 1 GB is sufficient (the default or lower can be used)
* **2–5 languages installed:** 2 GB is sufficient (the default is appropriate)
* **6–15 languages installed:** 3 GB is recommended (the setting should be increased)
* **15+ languages installed:** 4 GB is recommended (the setting should be increased)

{% hint style="warning" %}
Caution: If there isn’t enough memory available on the server or container, allocating more heap size won’t help. Check system resources first.
{% endhint %}

#### Early signs that more memory is needed

Monitor for these performance indicators that suggest the JVM heap size should be increased:

* Checks take noticeably longer to complete
* Server or container CPU usage spikes and stays high
* Timeout errors occur
* The application becomes unresponsive during peak usage

### How to adjust the JVM memory

The method depends on the deployment type. Follow the instructions for the appropriate setup below.

#### For Linux and Windows installations

{% hint style="info" %}
Before starting: Back up the original configuration file before making changes.
{% endhint %}

{% stepper %}
{% step %}

#### Locate the configuration file

Find the `AppServerX.xml` file in the installation directory.
{% endstep %}

{% step %}

#### Edit the file

Open the file with a text editor.
{% endstep %}

{% step %}

#### Modify JVM max memory

Find the line containing `<JVMMaxMemorySizeMb>` and replace `2048` with the desired value in megabytes. For example, enter `3072` for 3 GB or `4096` for 4 GB.
{% endstep %}

{% step %}

#### Save and close

Save the file and close the editor.
{% endstep %}

{% step %}

#### Restart the service

Restart AppServer to apply changes in `AppServerX.xml`.

To restart: [stop](https://docs.wproofreader.com/v6.12.0/deployment/configuration/grammar-check-engine-setup/pages/IA2KNQLXDh85TwDivL4y#mainappservercommands-stopappserverwindowslinux2.stopappserver) the application, then [start](https://docs.wproofreader.com/v6.12.0/deployment/configuration/grammar-check-engine-setup/pages/IA2KNQLXDh85TwDivL4y#mainappservercommands-startappserverwindowslinux1.startappserver) it again.

Use [Main AppServer commands](/v6.12.0/deployment/configuration/application-server/main-appserver-commands.md).
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Don’t set the heap size higher than 75% of the total available system memory. Doing so can cause the entire system to become unstable or unresponsive.
{% endhint %}

#### For Docker deployments

Configure the environment variable `WPR_JVM_MAX_MEMORY_SIZE_MB` with the desired value in megabytes.

Example docker run command:

```bash
docker run -d -p 80:8080 -e WPR_JVM_MAX_MEMORY_SIZE_MB=3072 <image_name>:<tag>
```

{% hint style="info" %}
Note: If this variable isn’t explicitly set, the application uses the default value of 2048 MB.
{% endhint %}

### Monitoring and troubleshooting

#### How to monitor performance

{% stepper %}
{% step %}
Check the server or container CPU usage during normal operation. A sustained CPU spike can indicate memory pressure.
{% endstep %}

{% step %}
Review application logs for garbage collection messages or out-of-memory errors. These messages indicate that memory allocation isn’t adequate for the workload.
{% endstep %}
{% endstepper %}

#### Common issues and solutions

<details>

<summary>Checks are still slow after increasing memory</summary>

This could indicate that memory isn’t the bottleneck. Check CPU usage, network latency, or language complexity. If the CPU is already at capacity, increasing memory won’t help unless out-of-memory errors occur.

</details>

<details>

<summary>The application won’t start after changing the memory setting</summary>

Verify that the entered value is a valid number (a whole number in megabytes). Check that other parts of the configuration file weren’t accidentally modified. Check logs for errors.

</details>

<details>

<summary>The memory value doesn’t seem to take effect</summary>

Confirm that the file was saved and the application was restarted. For Docker, verify that the container was actually redeployed and that the new environment variable was passed through the orchestration configuration.

</details>

<details>

<summary>Out-of-memory errors occur even with a high heap size</summary>

If the heap size has been set to 4 GB or higher and out-of-memory errors still occur, the system’s total available memory may be the limit. Consider upgrading the server hardware, removing unused language packs, or contacting support.

</details>

### Key points to remember

* The JVM heap size affects only the grammar component, not other proofreading features
* The default is 2048 MB; adjust based on installed languages
* CPU usage is a strong indicator of memory pressure; monitor it during grammar checks
* Always back up configuration files before editing
* Restart the application for changes to take effect
* Don’t allocate more than 75% of total system memory to the JVM

{% hint style="info" %}
Note: If performance issues continue after adjusting memory, contact support with details about the language configuration, system resources, and error logs.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wproofreader.com/v6.12.0/deployment/configuration/grammar-check-engine-setup/configure-jvm-maximum-heap-size.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
