> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/2.0/hosting/self-hosting/memory-limit.md).

# Memory limit

### Setting the limit

It is possible to define a soft limit on the amount of memory used by the Replication Server. To do this, the Replication Server process must be executed with a **GOMEMLIMIT** environment variable defined.&#x20;

From the [Go documentation](https://pkg.go.dev/runtime):

> GOMEMLIMIT is a numeric value in bytes with an optional unit suffix. The supported suffixes include B, KiB, MiB, GiB, and TiB.

For example, to set the limit to 4GB, you should export the following:

```
GOMEMLIMIT=4GiB
```

### Memory monitoring system

Replication Server uses a memory monitoring system that comes with a following thresholds:

#### High pressure @ 85% of memory used

When this threshold is reached any new client connections will be automatically rejected.

#### Critical pressure @ 95% of memory used

When this threshold is reached the Replication Server will stop a room that has the highest memory usage, in order to prevent the process being completely shutdown due to running Out Of Memory (OOM).


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.coherence.io/2.0/hosting/self-hosting/memory-limit.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
