# maxJvmHeapSize

> The maximum java heap size (in megabytes) that will be used for building Android applications.

## Definition

* **Type:** Property
* **Namespace:** [UnityEditor.Android](/engine/6000.7/script-reference/unityeditor/android.md)
* **Assembly:** UnityEditor.Android.Extensions

```csharp
public static int maxJvmHeapSize { get; set; }
```

### Remarks

By default, Unity uses 4096 MB and the minimum allowed value is 128 MB.

### Examples

```csharp
using UnityEngine;
using UnityEditor;
using UnityEditor.Android;

public class MaxJvmHeapSizeSample
{
    [MenuItem("Build/Set Custom Max JVM Heap Size")]
    public static void SetMaxJvmHeapSize()
    {
        // Set a custom maximum heap size for the JVM (in MB). Example: 1024 MB
        int customHeapSize = 1024;

        // Ensure the value is at least the minimum allowed (128 MB)
        if (customHeapSize >= 128)
        {
            AndroidExternalToolsSettings.maxJvmHeapSize = customHeapSize;
            Debug.Log($"Max JVM Heap Size set to: {AndroidExternalToolsSettings.maxJvmHeapSize} MB");
        }
        else
        {
            Debug.LogError($"Invalid heap size. The value must be at least 128 MB. Provided: {customHeapSize} MB");
        }
    }

    [MenuItem("Build/Get Current Max JVM Heap Size")]
    public static void GetMaxJvmHeapSize()
    {
        // Retrieve the currently configured maximum JVM heap size
        int currentHeapSize = AndroidExternalToolsSettings.maxJvmHeapSize;

        Debug.Log($"Current Max JVM Heap Size: {currentHeapSize} MB");

        // Display a warning if the configured heap size is below the minimum allowed
        if (currentHeapSize < 128)
        {
            Debug.LogWarning($"Warning: JVM Heap Size is less than the minimum allowed value (128 MB). Current value: {currentHeapSize} MB");
        }
    }
}
```
