# MEMORY DOCTOR

> Get a short plain-English report on memory problems the server can see.

URL: https://docs.hotkv.com/commands/memory-doctor/

```
MEMORY DOCTOR
```

- Group: Server
- Complexity: O(N) where N is the number of client connections
- HotKV Cloud: all plans
- On-Premise: no license needed

`MEMORY DOCTOR` looks at the server's memory figures and reports anything
that needs attention, with a hint about what to do. It checks for:

- the process holding much more memory than it uses (for example after a
  peak or many deletes), with a pointer to [MEMORY PURGE](https://docs.hotkv.com/commands/memory-purge/index.md)
- a peak well above the current use
- memory use close to `maxmemory`, and whether writes will then be
  refused or keys evicted, depending on `maxmemory-policy`
- a client with a large backlog of replies it has not read (a slow consumer;
  the `omem` field of [CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md) shows which)
- a replication backlog that takes a large share of the memory in use

When nothing is found, it summarises memory in use, memory held
by the process, and the peak.

## Return value

The report as text: a bulk string in RESP2, a verbatim string (`txt`) in
RESP3.

## Examples

```
127.0.0.1:6379> MEMORY DOCTOR
No memory problems found. In use: 88.21M, held by the process: 101.40M, peak: 92.35M.
127.0.0.1:6379> MEMORY DOCTOR
Memory report:
- Memory in use is 93.4% of maxmemory (1.00G): writes will evict keys (allkeys-lru) once it is reached.
```

## Compatibility

Redis 7 and Valkey 8 have the same command. The report's wording and the
checks it makes are HotKV's own, so don't parse the text.

## See also

[MEMORY STATS](https://docs.hotkv.com/commands/memory-stats/index.md), [MEMORY PURGE](https://docs.hotkv.com/commands/memory-purge/index.md),
[LATENCY DOCTOR](https://docs.hotkv.com/commands/latency-doctor/index.md), [INFO](https://docs.hotkv.com/commands/info/index.md)