# java.lang.OutOfMemoryError: Java heap space

For large projects with many classes to parse, the default JVM heap size might not suffice. If you encounter `java.lang.OutOfMemoryError: Java heap space` error consider increasing the `maxHeapSize` for the `test` source set:

{% tabs %}
{% tab title="Gradle (Kotlin)" %}
Add the following argument to the`build.gradle.kts` file:

```kotlin
tasks.withType<Test> {
    maxHeapSize = "1g"
}
```

{% endtab %}

{% tab title="Gradle (Groovy)" %}
Add the following argument to the `build.gradle` file:

```groovy
tasks.withType(Test).configureEach { 
    maxHeapSize = "1g" 
}
```

{% endtab %}

{% tab title="Maven" %}
Add the following argument to the `pom.xml` file:

```xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <argLine>-Xmx1g</argLine>
    </configuration>
</plugin>
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
You may need to set larger value than 1 gigabyte.
{% 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.konsist.lemonappdev.com/help/known-issues/java.lang.outofmemoryerror-java-heap-space.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.
