> For the complete documentation index, see [llms.txt](https://lodestone-technologies.gitbook.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodestone-technologies.gitbook.io/knowledgebase/minecraft-java/reduce-memory-usage.md).

# Reduce memory usage

Minecraft servers can experience memory issues, and reducing memory usage can help prevent these problems and optimise server performance effectively.

{% hint style="info" %}
We recommend using [Spark](/knowledgebase/minecraft-java/analyse-timings-with-spark.md) to analyse performance before attempting optimisation.
{% endhint %}

## Reducing chunk loading

The most common cause for memory issues is too many chunks being loaded at one time.&#x20;

The easiest way to change this is by changing the `view-distance` value in your `server.properties` file. This setting will reduce the number of  chunks that are loaded by your server, which will in turn reduce the amount of RAM your server is using.

## Changing startup flags

You can try using [Aikar's Flags](https://docs.papermc.io/paper/aikars-flags) to tune how the JVM does garbage collection, specifically how often a GC sweep runs, how long it's allowed to run, how old objects are allowed to be before getting garbage collected, number of cores used for GC sweeps, etc.

## Removing unhelpful plugins

We recommend removing plugins, such as ClearLagg, that clear server entities. They tend to use more resources scanning and removing items than not removing the items at all.

You should also remove mob stacker plugins unless strictly required, as stacking naturally spawned entities causes more lag than not stacking them at all due to the server constantly trying to spawn more mobs.

## Advanced optimisation

You can try following an [optimisation guide](https://github.com/YouHaveTrouble/minecraft-optimization) to configure server settings and improve performance. It's important to remember that you'll need to tune this to your server's requirements.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://lodestone-technologies.gitbook.io/knowledgebase/minecraft-java/reduce-memory-usage.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.
