Skip to content

Allow linking alternate memory management implementations#454

Merged
hummeltech merged 3 commits intoopenstreetmap:masterfrom
hummeltech:AlternateMalloc
Jun 29, 2024
Merged

Allow linking alternate memory management implementations#454
hummeltech merged 3 commits intoopenstreetmap:masterfrom
hummeltech:AlternateMalloc

Conversation

@hummeltech
Copy link
Copy Markdown
Collaborator

With new CMake CACHE entry MALLOC_LIB, supporting the following values:

rolandbosa and others added 3 commits June 28, 2024 15:58
The core issue seems to be the memory management combined with the memory usage pattern of renderd.

The glib-provided heap implementation somehow fails to give back memory to the system, but instead keeps on growing the data segment until the system decides to kill the process.

The jemalloc implementation puts allocations into arenas and once they are freed (and some time has passed), they are given back to the system and seem to reduce the RSS size of the process.

This should address/alleviate openstreetmap#181
Default is `glib`, which seems to have issues with increased memory consumption.

Alternatives are `jemalloc` and `tcmalloc`.

To select a different library, configure the build folder, then run `ccmake <build_folder>` to configure the option `MALLOC_LIB`. For automated configuration, run, add `-DMALLOC_LIB=jemalloc` or `-DMALLOC_LIB=tcmalloc` to the `cmake` configuration command line.
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.26%. Comparing base (c4e3e62) to head (b3b39bc).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
+ Coverage   81.54%   84.26%   +2.72%     
==========================================
  Files          24       24              
  Lines        5645     5321     -324     
==========================================
- Hits         4603     4484     -119     
+ Misses       1042      837     -205     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hummeltech hummeltech merged commit 0478a1b into openstreetmap:master Jun 29, 2024
@hummeltech hummeltech deleted the AlternateMalloc branch June 29, 2024 01:08
hummeltech added a commit that referenced this pull request Jun 29, 2024
…454)

With new `CMake CACHE` entry `MALLOC_LIB`, supporting the following values:
* `libc` (default): Use the system's implementation
* `jemalloc`: Use [jemalloc](http://jemalloc.net)
* `mimalloc`: Use [mimalloc](https://github.com/microsoft/mimalloc)
* `tcmalloc`: Use [tcmalloc](https://github.com/google/tcmalloc)

Co-authored-by: Roland Bosa <roland.bosa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants