prestodb/presto · error · PrestoException
MEMORY_LIMIT_EXCEEDED
MEMORY_LIMIT_EXCEEDED
Error message
Memory limit [%d] for memory connector exceeded
What it means
MemoryPagesStore.add throws MEMORY_LIMIT_EXCEEDED when adding a page would push currentBytes past maxBytes, the memory connector's per-store cap (memory.max-data-per-node / configured max bytes). The memory connector is in-memory only; it never spills, so exceeding the budget aborts the write.
Source
Thrown at presto-memory/src/main/java/com/facebook/presto/plugin/memory/MemoryPagesStore.java:69
public synchronized void initialize(long tableId)
{
if (!tables.containsKey(tableId)) {
tables.put(tableId, new TableData());
}
}
public synchronized void add(Long tableId, Page page)
{
if (!contains(tableId)) {
throw new PrestoException(MISSING_DATA, "Failed to find table on a worker.");
}
page.compact();
long newSize = currentBytes + page.getRetainedSizeInBytes();
if (maxBytes < newSize) {
throw new PrestoException(MEMORY_LIMIT_EXCEEDED, format("Memory limit [%d] for memory connector exceeded", maxBytes));
}
currentBytes = newSize;
TableData tableData = tables.get(tableId);
tableData.add(page);
}
public synchronized List<Page> getPages(
Long tableId,
int partNumber,
int totalParts,
List<Integer> columnIndexes,
long expectedRows)
{
if (!contains(tableId)) {
throw new PrestoException(MISSING_DATA, "Failed to find table on a worker.");
}
TableData tableData = tables.get(tableId);View on GitHub (pinned to 55bb57d202)
Solutions
- Increase the connector's maxBytes (memory.max-data-per-node in catalog properties) and/or worker heap.
- Load only a subset of the data, or switch to a spilling connector (Hive/Iceberg) for large datasets.
- Page.compact() already trims retained size — reduce wide column usage (e.g. large VARCHAR/map/array) in the memory table.
- Ensure no leaked/abandoned tables are holding memory; restart the worker or drop unused memory tables to reclaim space.
Example fix
// catalog/memory.properties // before memory.max-data-per-node=1GB // after memory.max-data-per-node=16GB
Defensive patterns
Strategy: validation
Validate before calling
if (estimatedRetainedBytes + currentUsageBytes > maxBytesPerNode) throw new IllegalArgumentException("Dataset too large for memory connector"); Try / catch
try { insert(...) } catch (PrestoException e) { if (MEMORY_LIMIT_EXCEEDED.equals(e.getErrorCode())) { /* switch to Hive/Iceberg or raise limit */ } else throw e; } Prevention
- Size memory.max-data-per-node to your largest expected table plus headroom
- Use the memory connector only for small test datasets
- Monitor currentBytes via connector stats/JMX
When it happens
Trigger: INSERT/CREATE TABLE AS into a memory table whose accumulated retained size plus the new page exceeds maxBytes on that worker.
Common situations: Loading large datasets into the memory connector for fast testing; underestimated row sizes (wide/complex types); concurrent inserts filling the same worker's store; max-bytes-per-node configured too low.
Related errors
- Can not grow array beyond '%s'
- GENERIC_INSUFFICIENT_RESOURCES
- GENERIC_INSUFFICIENT_RESOURCES
- GENERIC_INSUFFICIENT_RESOURCES
- NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/28c1403dc61e134b.
Report an issue: GitHub.