diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 19498237c..1704b182e 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -111,12 +111,6 @@ else srs_undefine_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H fi -if [ $SRS_MEM_WATCH = YES ]; then - srs_define_macro "SRS_MEM_WATCH" $SRS_AUTO_HEADERS_H -else - srs_undefine_macro "SRS_MEM_WATCH" $SRS_AUTO_HEADERS_H -fi - if [ $SRS_UTEST = YES ]; then srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H else diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 169328a9e..ca7d6dac8 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -76,9 +76,6 @@ SRS_LOG_TRACE=YES # donot compile ssl, use system ssl(-lssl) if required. # TODO: Use pkg-config to get the openssl path. SRS_USE_SYS_SSL=NO -# enable memory watch, detect memory leak, -# similar to gmc, should disable in release version for hurts performance. -SRS_MEM_WATCH=NO # export the srs-librtmp to specified project, NO to disable it. SRS_EXPORT_LIBRTMP_PROJECT=NO # export the srs-librtmp to a single .h and .c, NO to disable it. @@ -376,7 +373,6 @@ function parse_user_option() { --disable-all) SRS_DISABLE_ALL=YES ;; --pure-rtmp) SRS_PURE_RTMP=YES ;; --full) SRS_ENABLE_ALL=YES ;; - --memory-watch) SRS_MEM_WATCH=YES ;; --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;; --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;; --with-nginx) SRS_NGINX=YES ;; diff --git a/trunk/configure b/trunk/configure index 2b0f5be21..c49825233 100755 --- a/trunk/configure +++ b/trunk/configure @@ -204,7 +204,7 @@ MODULE_ID="CORE" MODULE_DEPENDS=() ModuleLibIncs=(${SRS_OBJS_DIR}) MODULE_FILES=("srs_core" "srs_core_version4" "srs_core_autofree" "srs_core_performance" - "srs_core_mem_watch" "srs_core_time") + "srs_core_time") CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh CORE_OBJS="${MODULE_OBJS[@]}" # diff --git a/trunk/ide/srs_upp/srs_upp.upp b/trunk/ide/srs_upp/srs_upp.upp index 3c82bed66..36f931238 100755 --- a/trunk/ide/srs_upp/srs_upp.upp +++ b/trunk/ide/srs_upp/srs_upp.upp @@ -9,8 +9,6 @@ file ../../src/core/srs_core.cpp, ../../src/core/srs_core_autofree.hpp, ../../src/core/srs_core_autofree.cpp, - ../../src/core/srs_core_mem_watch.hpp, - ../../src/core/srs_core_mem_watch.cpp, ../../src/core/srs_core_performance.hpp, ../../src/core/srs_core_performance.cpp, kernel readonly separator, diff --git a/trunk/ide/srs_vs2010/srs.vcxproj b/trunk/ide/srs_vs2010/srs.vcxproj index 95673b490..5c153cca3 100755 --- a/trunk/ide/srs_vs2010/srs.vcxproj +++ b/trunk/ide/srs_vs2010/srs.vcxproj @@ -101,7 +101,6 @@ - @@ -167,7 +166,6 @@ - diff --git a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj index 8f1ae9bd4..091a53f44 100644 --- a/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj +++ b/trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj @@ -81,7 +81,6 @@ 3C4AB9331B8C9148006627D3 /* srs_app_ng_exec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C4AB9311B8C9148006627D3 /* srs_app_ng_exec.cpp */; }; 3C4D184C1E73F133008806F7 /* srs_app_fragment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C4D184A1E73F133008806F7 /* srs_app_fragment.cpp */; }; 3C4F97121B8B466D00FF0E46 /* srs_app_process.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C4F97101B8B466D00FF0E46 /* srs_app_process.cpp */; }; - 3C5265B41B241BF0009CA186 /* srs_core_mem_watch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */; }; 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */; }; 3C663F101AB0155100286D8B /* srs_audio_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */; }; 3C6F2D751E8653BF003D0805 /* srs_main_mp4_parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C6F2D741E8653BF003D0805 /* srs_main_mp4_parser.cpp */; }; @@ -343,7 +342,6 @@ 3C4D184B1E73F133008806F7 /* srs_app_fragment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_fragment.hpp; path = ../../../src/app/srs_app_fragment.hpp; sourceTree = ""; }; 3C4F97101B8B466D00FF0E46 /* srs_app_process.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_process.cpp; path = ../../../src/app/srs_app_process.cpp; sourceTree = ""; }; 3C4F97111B8B466D00FF0E46 /* srs_app_process.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_process.hpp; path = ../../../src/app/srs_app_process.hpp; sourceTree = ""; }; - 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_core_mem_watch.cpp; path = ../../../src/core/srs_core_mem_watch.cpp; sourceTree = ""; }; 3C6673CF1DF7B93200A6DF57 /* readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = readme.txt; path = ../../../modules/readme.txt; sourceTree = ""; }; 3C6673D11DF7B95E00A6DF57 /* config */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = config; path = "../../../modules/hls-ingester/config"; sourceTree = ""; }; 3C6F2D731E86536B003D0805 /* config */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = config; path = "../../../modules/mp4-parser/config"; sourceTree = ""; }; @@ -473,8 +471,6 @@ children = ( 3C1231F01AAE652C00CE8F6C /* srs_core_autofree.cpp */, 3C1231F11AAE652C00CE8F6C /* srs_core_autofree.hpp */, - 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */, - 3C5265B31B241BF0009CA186 /* srs_core_mem_watch.hpp */, 3C1231F21AAE652C00CE8F6C /* srs_core_performance.cpp */, 3C1231F31AAE652C00CE8F6C /* srs_core_performance.hpp */, 3C1231F41AAE652D00CE8F6C /* srs_core.cpp */, @@ -984,7 +980,6 @@ 3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */, 3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */, 8C0652B12035B5BA000B0661 /* srs_app_coworkers.cpp in Sources */, - 3C5265B41B241BF0009CA186 /* srs_core_mem_watch.cpp in Sources */, 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */, 3C82802C1BAFF8CC004A1794 /* srs_kafka_stack.cpp in Sources */, 3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */, diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 5bfe48111..39141bf55 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -50,7 +50,6 @@ using namespace std; #include #include #include -#include #include #include #include @@ -745,10 +744,6 @@ void SrsServer::dispose() _srs_sources->dispose(); // @remark don't dispose all connections, for too slow. - -#ifdef SRS_MEM_WATCH - srs_memory_report(); -#endif } void SrsServer::gracefully_dispose() @@ -790,10 +785,6 @@ void SrsServer::gracefully_dispose() _srs_sources->dispose(); srs_trace("source disposed"); -#ifdef SRS_MEM_WATCH - srs_memory_report(); -#endif - srs_usleep(_srs_config->get_grace_final_wait()); srs_trace("final wait for %dms", srsu2msi(_srs_config->get_grace_final_wait())); } @@ -1169,10 +1160,6 @@ void SrsServer::on_signal(int signo) #ifdef SRS_GPERF_MC srs_trace("gmc is on, main cycle will terminate normally, signo=%d", signo); signal_gmc_stop = true; -#else - #ifdef SRS_MEM_WATCH - srs_memory_report(); - #endif #endif } diff --git a/trunk/src/core/srs_core_mem_watch.cpp b/trunk/src/core/srs_core_mem_watch.cpp deleted file mode 100644 index bc39e8523..000000000 --- a/trunk/src/core/srs_core_mem_watch.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2013-2020 Winlin - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include - -#ifdef SRS_MEM_WATCH - -#include -#include -using namespace std; - -struct SrsMemoryObject -{ - void* ptr; - std::string category; - int size; -}; - -std::map _srs_ptrs; - -void srs_memory_watch(void* ptr, string category, int size) -{ - SrsMemoryObject* obj = NULL; - - std::map::iterator it; - if ((it = _srs_ptrs.find(ptr)) != _srs_ptrs.end()) { - obj = it->second; - } else { - obj = new SrsMemoryObject(); - _srs_ptrs[ptr] = obj; - } - - obj->ptr = ptr; - obj->category = category; - obj->size = size; -} - -void srs_memory_unwatch(void* ptr) -{ - std::map::iterator it; - if ((it = _srs_ptrs.find(ptr)) != _srs_ptrs.end()) { - SrsMemoryObject* obj = it->second; - srs_freep(obj); - - _srs_ptrs.erase(it); - } -} - -void srs_memory_report() -{ - printf("srs memory watch leak report:\n"); - - int total = 0; - std::map::iterator it; - for (it = _srs_ptrs.begin(); it != _srs_ptrs.end(); ++it) { - SrsMemoryObject* obj = it->second; - printf(" %s: %#" PRIx64 ", %dB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size); - total += obj->size; - } - - printf("%d objects leak %dKB.\n", (int)_srs_ptrs.size(), total / 1024); - printf("@remark use script to cleanup for memory watch: ./etc/init.d/srs stop\n"); -} - -#endif - diff --git a/trunk/src/core/srs_core_mem_watch.hpp b/trunk/src/core/srs_core_mem_watch.hpp deleted file mode 100644 index bbd154a15..000000000 --- a/trunk/src/core/srs_core_mem_watch.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2013-2020 Winlin - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef SRS_CORE_MEM_WATCH_HPP -#define SRS_CORE_MEM_WATCH_HPP - -#include - -#ifdef SRS_MEM_WATCH - -#warning "MemoryWatch is deprecated." - -#include - -// Watch the specified memory. -extern void srs_memory_watch(void* ptr, std::string category, int size); - -// Unwatch the specified memory. -extern void srs_memory_unwatch(void* ptr); - -// Report the memory watch. -extern void srs_memory_report(); - -#endif - -#endif - diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index edbcb829c..ff41f6f4c 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -38,7 +38,6 @@ using namespace std; #include #include #include -#include #include SrsMessageHeader::SrsMessageHeader() @@ -161,9 +160,6 @@ SrsCommonMessage::SrsCommonMessage() SrsCommonMessage::~SrsCommonMessage() { -#ifdef SRS_MEM_WATCH - srs_memory_unwatch(payload); -#endif srs_freepa(payload); } @@ -173,10 +169,6 @@ void SrsCommonMessage::create_payload(int size) payload = new char[size]; srs_verbose("create payload for RTMP message. size=%d", size); - -#ifdef SRS_MEM_WATCH - srs_memory_watch(payload, "RTMP.msg.payload", size); -#endif } srs_error_t SrsCommonMessage::create(SrsMessageHeader* pheader, char* body, int size) @@ -211,9 +203,6 @@ SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() SrsSharedPtrMessage::SrsSharedPtrPayload::~SrsSharedPtrPayload() { -#ifdef SRS_MEM_WATCH - srs_memory_unwatch(payload); -#endif srs_freepa(payload); } diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 65fc1cb65..d1657d2bc 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -355,11 +355,6 @@ void show_macro_features() srs_trace("system default latency(ms): mw(0-%d) + mr(0-%d) + play-queue(0-%d)", srsu2msi(SRS_PERF_MW_SLEEP), possible_mr_latency, srsu2msi(SRS_PERF_PLAY_QUEUE)); -#ifdef SRS_MEM_WATCH -#warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script." - srs_warn("srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."); -#endif - #if VERSION_MAJOR > VERSION_STABLE #warning "Current branch is not stable." srs_warn("%s/%s is not stable", RTMP_SIG_SRS_KEY, RTMP_SIG_SRS_VERSION);