DBAtlas · Database operations atlas

Memory pressure / OOM

Symptom

The OOM killer kills the process, 'out of memory', low cache hit ratio, excessive swapping, Redis 'OOM command not allowed'.

1. Who is consuming memory

Is it the DB's allocated memory (buffer pool/SGA), per-session memory (PGA/sort/work_mem), or the OS as a whole? Check free/vmstat at the OS level and the memory views inside the DB.

Oracle

SELECT component, current_size/1048576 mb FROM v$memory_dynamic_components WHERE current_size>0;

PostgreSQL

SHOW shared_buffers; SHOW work_mem; -- work_mem * connections * number of sorts can blow up in total

MySQL

SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; SHOW STATUS LIKE 'Innodb_buffer_pool%';

Redis

INFO memory  # used_memory, maxmemory, mem_fragmentation_ratio

2. Separate configuration from load

Does the total of the memory settings exceed physical RAM (over-commit)? Calculate shared_buffers + (work_mem * concurrency). Or is it a momentary load (a huge sort/hash, many connections)?

3. Redis-specific: eviction and fragmentation

If used_memory has hit maxmemory, check maxmemory-policy (with noeviction, writes are rejected). If mem_fragmentation_ratio is high, use MEMORY PURGE / activedefrag. Find big keys with --bigkeys.

Redis

CONFIG GET maxmemory-policy
MEMORY DOCTOR
redis-cli --bigkeys

4. Relieve immediately

Kill the runaway query/session eating memory, temporarily lower session memory such as work_mem, drop unnecessary connections. If the system is swapping, getting out of swap is the priority.

5. Size correctly

Distribute RAM correctly with the Tools > Memory/Buffer Pool calculator. General rule: on a dedicated server, buffer pool/SGA ~70-80% of RAM; total session memory multiplied by concurrency and do not exceed RAM. Add RAM if necessary.

Open in DBAtlas →