Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void setNoMorePages()
stateMachine.finish();
}
exchangeSink = null;
updateMemoryUsage(0);
forceFreeMemory();
});
}

Expand Down Expand Up @@ -234,7 +234,7 @@ public void abort()
log.warn(failure, "Error aborting exchange sink");
}
exchangeSink = null;
updateMemoryUsage(0);
forceFreeMemory();
});
}

Expand Down Expand Up @@ -272,6 +272,14 @@ private void updatePeakMemoryUsage(long bytes)
}
}

private void forceFreeMemory()
{
LocalMemoryContext context = getSystemMemoryContextOrNull();
if (context != null) {
context.close();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not every memory context is closeable, see https://github.com/trinodb/trino/pull/13213/files#diff-1774b86bf4c8b2248f02693fe0b0c6acc38305a6773ca813f5957601207a8168R338.
I think we can assume that only memory context created from io.trino.memory.context.AggregatedMemoryContext#newAggregatedMemoryContext are closeable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

private LocalMemoryContext getSystemMemoryContextOrNull()
{
try {
Expand Down