1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
Optionally disable jemalloc
Telegram upstream heavily insists you use the jemalloc allocator. This is due
to the high memory usage resulting from the glibc allocator. It is unknown why
this affects telegram the way it does, but upstream solved the issue by using a
different allocator. Initially they used mallocng, now jemalloc.
However, other libcs don't necessarily need this, and as such this should be
optional. As mallocng is a fork of musl's allocator, and this was used before
the switch to jemalloc, the musl allocator should still be OK.
Please warn glibc users about disabling jemalloc, don't report bugs about
memory usage upstream unless you're using jemalloc.
Related info:
https://github.com/telegramdesktop/tdesktop/issues/16084
https://github.com/desktop-app/cmake_helpers/pull/91#issuecomment-881788003
--- tdesktop-3.5.2-full.orig/Telegram/CMakeLists.txt
+++ tdesktop-3.5.2-full/Telegram/CMakeLists.txt
@@ -1358,11 +1358,13 @@
)
endif()
- target_link_libraries(Telegram
- PRIVATE
- desktop-app::linux_jemalloc_helper
- $<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
- )
+ if (NOT DESKTOP_APP_DISABLE_JEMALLOC)
+ target_link_libraries(Telegram
+ PRIVATE
+ desktop-app::linux_jemalloc_helper
+ $<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
+ )
+ endif()
endif()
if (build_macstore)
--- tdesktop-3.5.2-full.orig/cmake/CMakeLists.txt
+++ tdesktop-3.5.2-full/cmake/CMakeLists.txt
@@ -5,7 +5,7 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_subdirectory(external)
-if (LINUX)
+if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
add_subdirectory(linux_jemalloc_helper)
endif()
if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
--- tdesktop-3.5.2-full.orig/cmake/external/CMakeLists.txt
+++ tdesktop-3.5.2-full/cmake/external/CMakeLists.txt
@@ -37,7 +37,7 @@
add_checked_subdirectory(hunspell)
endif()
add_checked_subdirectory(iconv)
-if (LINUX)
+if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
add_checked_subdirectory(jemalloc)
endif()
add_checked_subdirectory(jpeg)
--- tdesktop-3.5.2-full.orig/cmake/variables.cmake
+++ tdesktop-3.5.2-full/cmake/variables.cmake
@@ -26,6 +26,7 @@
option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled patched ones." OFF)
option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled patched one." OFF)
option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF)
+option(DESKTOP_APP_DISABLE_JEMALLOC "Disable use of the jemalloc allocator (Linux only)." OFF)
option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target})
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)
|