Introduce DESKTOP_APP_DISABLE_JEMALLOC to enable using system malloc
On at least OpenBSD, malloc(3) is preferred to other implementations like jemalloc for various reasons. It is common for portable third-party software (ports) to provide a switch for en/disabling jemalloc. tdesktop makes this easy since it does not contain any (je)malloc specific code (anymore). Introduce a new default-off option that disables jemalloc when enabled explicitly; this also allow developers and package maintainers more easily to try different malloc implementations, e.g. for debugging. Memory leaks reported in the slightly old issue "The app consumes an unexpectedly large amount of RAM" https://github.com/telegramdesktop/tdesktop/issues/16084 could not be reproduced on OpenBSD/amd64 with malloc(3) using tdesktop >= 3.3.1.
This commit is contained in:
parent
a82b114980
commit
ddd1ee547d
4 changed files with 11 additions and 4 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
|
||||||
add_subdirectory(external)
|
add_subdirectory(external)
|
||||||
if (LINUX)
|
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||||
add_subdirectory(linux_jemalloc_helper)
|
add_subdirectory(linux_jemalloc_helper)
|
||||||
endif()
|
endif()
|
||||||
if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
|
if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
|
||||||
|
|
|
||||||
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
|
|
@ -37,7 +37,7 @@ if (add_hunspell_library)
|
||||||
add_checked_subdirectory(hunspell)
|
add_checked_subdirectory(hunspell)
|
||||||
endif()
|
endif()
|
||||||
add_checked_subdirectory(iconv)
|
add_checked_subdirectory(iconv)
|
||||||
if (LINUX)
|
if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||||
add_checked_subdirectory(jemalloc)
|
add_checked_subdirectory(jemalloc)
|
||||||
endif()
|
endif()
|
||||||
add_checked_subdirectory(jpeg)
|
add_checked_subdirectory(jpeg)
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,16 @@ if (DESKTOP_APP_SPECIAL_TARGET)
|
||||||
target_link_options(common_options INTERFACE $<IF:$<CONFIG:Debug>,,-g -flto -fuse-linker-plugin>)
|
target_link_options(common_options INTERFACE $<IF:$<CONFIG:Debug>,,-g -flto -fuse-linker-plugin>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT DESKTOP_APP_DISABLE_JEMALLOC)
|
||||||
|
target_link_libraries(common_options
|
||||||
|
INTERFACE
|
||||||
|
$<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
|
||||||
|
$<LINK_ONLY:desktop-app::external_jemalloc>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(common_options
|
target_link_libraries(common_options
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
|
|
||||||
$<LINK_ONLY:desktop-app::external_jemalloc>
|
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate
|
||||||
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
|
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
|
||||||
option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF)
|
option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF)
|
||||||
option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF)
|
option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF)
|
||||||
|
option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc (Linux only)." OFF)
|
||||||
|
|
||||||
if (DESKTOP_APP_USE_PACKAGED AND DEFINED CMAKE_OSX_ARCHITECTURES)
|
if (DESKTOP_APP_USE_PACKAGED AND DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||||
set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch. (macOS only)")
|
set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch. (macOS only)")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue