# 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: 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.coherence.io/hosting/self-hosting/memory-limit.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.
