Skip to content

Instantly share code, notes, and snippets.

@seanlinsley
Created June 25, 2023 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanlinsley/e860b2fad7b8badaa43987cb4140ffa9 to your computer and use it in GitHub Desktop.
Save seanlinsley/e860b2fad7b8badaa43987cb4140ffa9 to your computer and use it in GitHub Desktop.
Prevent memory bloat on Linux with malloc_trim(0)

The default allocator on Linux has a tendency to free unused memory less aggressively than Mac and Windows. This creates the appearance of memory bloat. Calling malloc_trim(0) may not prevent out of memory events of that single process, but it helps you see the real memory usage, and frees up memory for use by other processes.

Relevant links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment