mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-30 16:27:36 +08:00
升级jemalloc到5.3版本 (#2884)
升级jemalloc到5.3版本,相比5.2.1内存稳定许多,去除--without-export编译参数, 解决类似glibc中分配内存却在jemalloc中释放导致崩溃问题. 比如: toolkit::LoggerWrapper::printLogV中使用的vasprintf
This commit is contained in:
parent
48f62810c7
commit
db3f0147be
@ -39,6 +39,7 @@ option(ENABLE_FAAC "Enable FAAC" OFF)
|
|||||||
option(ENABLE_FFMPEG "Enable FFmpeg" OFF)
|
option(ENABLE_FFMPEG "Enable FFmpeg" OFF)
|
||||||
option(ENABLE_HLS "Enable HLS" ON)
|
option(ENABLE_HLS "Enable HLS" ON)
|
||||||
option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" OFF)
|
option(ENABLE_JEMALLOC_STATIC "Enable static linking to the jemalloc library" OFF)
|
||||||
|
option(ENABLE_JEMALLOC_DUMP "Enable jemalloc to dump malloc statistics" OFF)
|
||||||
option(ENABLE_MEM_DEBUG "Enable Memory Debug" OFF)
|
option(ENABLE_MEM_DEBUG "Enable Memory Debug" OFF)
|
||||||
option(ENABLE_MP4 "Enable MP4" ON)
|
option(ENABLE_MP4 "Enable MP4" ON)
|
||||||
option(ENABLE_HLS_FMP4 "Enable HLS-FMP4" ON)
|
option(ENABLE_HLS_FMP4 "Enable HLS-FMP4" ON)
|
||||||
@ -335,7 +336,11 @@ if(ENABLE_JEMALLOC_STATIC)
|
|||||||
if(NOT EXISTS ${DEP_ROOT_DIR})
|
if(NOT EXISTS ${DEP_ROOT_DIR})
|
||||||
file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
|
file(MAKE_DIRECTORY ${DEP_ROOT_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
if (ENABLE_JEMALLOC_DUMP)
|
||||||
|
set(ENABLE_JEMALLOC_STAT ON)
|
||||||
|
else ()
|
||||||
|
set(ENABLE_JEMALLOC_STAT OFF)
|
||||||
|
endif ()
|
||||||
include(Jemalloc)
|
include(Jemalloc)
|
||||||
include_directories(SYSTEM ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
|
include_directories(SYSTEM ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/include/jemalloc)
|
||||||
link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
|
link_directories(${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib)
|
||||||
@ -349,6 +354,12 @@ if(JEMALLOC_FOUND)
|
|||||||
message(STATUS "found library: ${JEMALLOC_LIBRARIES}")
|
message(STATUS "found library: ${JEMALLOC_LIBRARIES}")
|
||||||
include_directories(${JEMALLOC_INCLUDE_DIR})
|
include_directories(${JEMALLOC_INCLUDE_DIR})
|
||||||
update_cached_list(MK_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
update_cached_list(MK_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
|
||||||
|
add_definitions(-DUSE_JEMALLOC)
|
||||||
|
message(STATUS "jemalloc will be used to avoid memory fragmentation")
|
||||||
|
if (ENABLE_JEMALLOC_DUMP)
|
||||||
|
add_definitions(-DENABLE_JEMALLOC_DUMP)
|
||||||
|
message(STATUS "jemalloc will save memory usage statistics when the program exits")
|
||||||
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# 查找 openssl 是否安装
|
# 查找 openssl 是否安装
|
||||||
|
@ -1,21 +1,34 @@
|
|||||||
# Download and build Jemalloc
|
# Download and build Jemalloc
|
||||||
|
|
||||||
set(JEMALLOC_VERSION 5.2.1)
|
set(JEMALLOC_VERSION 5.3.0)
|
||||||
set(JEMALLOC_NAME jemalloc-${JEMALLOC_VERSION})
|
set(JEMALLOC_NAME jemalloc-${JEMALLOC_VERSION})
|
||||||
set(JEMALLOC_TAR_PATH ${DEP_ROOT_DIR}/${JEMALLOC_NAME}.tar.bz2)
|
set(JEMALLOC_TAR_PATH ${DEP_ROOT_DIR}/${JEMALLOC_NAME}.tar.bz2)
|
||||||
|
|
||||||
list(APPEND jemalloc_CONFIG_ARGS --disable-initial-exec-tls)
|
list(APPEND jemalloc_CONFIG_ARGS --disable-initial-exec-tls)
|
||||||
list(APPEND jemalloc_CONFIG_ARGS --without-export)
|
#list(APPEND jemalloc_CONFIG_ARGS --without-export)
|
||||||
|
if (ENABLE_JEMALLOC_STAT)
|
||||||
|
list(APPEND jemalloc_CONFIG_ARGS --enable-stats)
|
||||||
|
message(STATUS "Jemalloc stats enabled")
|
||||||
|
else ()
|
||||||
list(APPEND jemalloc_CONFIG_ARGS --disable-stats)
|
list(APPEND jemalloc_CONFIG_ARGS --disable-stats)
|
||||||
|
message(STATUS "Jemalloc stats disabled")
|
||||||
|
endif ()
|
||||||
list(APPEND jemalloc_CONFIG_ARGS --disable-libdl)
|
list(APPEND jemalloc_CONFIG_ARGS --disable-libdl)
|
||||||
#list(APPEND jemalloc_CONFIG_ARGS --disable-cxx)
|
#list(APPEND jemalloc_CONFIG_ARGS --disable-cxx)
|
||||||
#list(APPEND jemalloc_CONFIG_ARGS --with-jemalloc-prefix=je_)
|
#list(APPEND jemalloc_CONFIG_ARGS --with-jemalloc-prefix=je_)
|
||||||
#list(APPEND jemalloc_CONFIG_ARGS --enable-debug)
|
#list(APPEND jemalloc_CONFIG_ARGS --enable-debug)
|
||||||
|
|
||||||
if(NOT EXISTS ${JEMALLOC_TAR_PATH})
|
if(NOT EXISTS ${JEMALLOC_TAR_PATH})
|
||||||
message(STATUS "Downloading ${JEMALLOC_NAME}...")
|
set(JEMALLOC_URL https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_NAME}.tar.bz2)
|
||||||
file(DOWNLOAD https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_NAME}.tar.bz2
|
message(STATUS "Downloading ${JEMALLOC_NAME} from ${JEMALLOC_URL}")
|
||||||
${JEMALLOC_TAR_PATH})
|
file(DOWNLOAD ${JEMALLOC_URL} ${JEMALLOC_TAR_PATH} SHOW_PROGRESS STATUS JEMALLOC_DOWNLOAD_STATUS LOG JEMALLOC_DOWNLOAD_LOG)
|
||||||
|
list(GET JEMALLOC_DOWNLOAD_STATUS 0 JEMALLOC_DOWNLOAD_STATUS_CODE)
|
||||||
|
if(NOT JEMALLOC_DOWNLOAD_STATUS_CODE EQUAL 0)
|
||||||
|
file(REMOVE ${JEMALLOC_TAR_PATH})
|
||||||
|
message(STATUS "${JEMALLOC_DOWNLOAD_LOG}")
|
||||||
|
message(FATAL_ERROR "${JEMALLOC_NAME} download failed! error is ${JEMALLOC_DOWNLOAD_STATUS}")
|
||||||
|
return()
|
||||||
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET( DIR_CONTAINING_JEMALLOC ${DEP_ROOT_DIR}/${JEMALLOC_NAME} )
|
SET( DIR_CONTAINING_JEMALLOC ${DEP_ROOT_DIR}/${JEMALLOC_NAME} )
|
||||||
|
Loading…
Reference in New Issue
Block a user