Skip to content

Commit

Permalink
Reduce memory usage of renderd
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rolandbosa committed Jul 1, 2024
1 parent 3120d0b commit 000a6ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ include(GNUInstallDirs)
find_package(ICU REQUIRED uc)
find_package(Threads REQUIRED)

# Switch to jemalloc (http://jemalloc.net) as the malloc/free
# implementation in renderd.
# Should address https://github.com/openstreetmap/mod_tile/issues/181
find_package(PkgConfig REQUIRED)
pkg_check_modules(JEMALLOC jemalloc)
pkg_search_module(JEMALLOC REQUIRED jemalloc)

find_package(APR REQUIRED)
find_package(GLIB 2.50 REQUIRED)
find_package(HTTPD 2.4 REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ set(renderd_SRCS
renderd.c
request_queue.c
)
# JEMALLOC libraries should come *before* the GLIB libraries.
set(renderd_LIBS
${JEMALLOC_LIBRARIES}
${ICU_LIBRARIES}
${LIBMAPNIK_LIBRARIES}
${RENDER_LIBRARIES}
Expand Down

0 comments on commit 000a6ca

Please sign in to comment.