Out of memory — restart server and try again
Production Risk
Critical — server cannot process queries; may require restart.
ER_OUTOFMEMORY (1037, SQLSTATE HY001) is raised when MySQL cannot allocate memory for an operation. This can be caused by insufficient RAM, excessively large per-session buffers, or a memory leak.
- 1Server is under memory pressure due to many concurrent connections
- 2Per-session buffers (sort_buffer_size, join_buffer_size) are set too large
- 3A single query requires more memory than available (e.g., very large IN list or BLOB handling)
-- No single trigger SQL; occurs when memory allocation fails
expected output
ERROR 1037 (HY001): Out of memory; restart server and try again (needed 1234567 bytes)
Fix
Reduce per-session buffer sizes
WHEN Many concurrent connections are exhausting memory.
SET GLOBAL sort_buffer_size = 262144; -- 256 KB SET GLOBAL join_buffer_size = 262144; -- 256 KB SET GLOBAL read_buffer_size = 131072; -- 128 KB
Why this works
Per-session buffers are allocated for each connection; reducing them allows more concurrent connections within the same RAM budget.
✕ Restart the server without investigating the cause
Restarting relieves the symptom but does not fix the underlying over-allocation; the error will recur under the same load.
MySQL 8.0 — 1037 ER_OUTOFMEMORY
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev