From 573495a19f1c3ce2a98fc348f42f45b3b6efee6d Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 8 Jun 2015 09:47:45 +0800 Subject: [PATCH] refine the memory watcher. --- trunk/src/app/srs_app_source.cpp | 6 ++++++ trunk/src/core/srs_core_mem_watch.cpp | 2 +- trunk/src/core/srs_core_performance.hpp | 2 +- trunk/src/main/srs_main_server.cpp | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 2a5417a9d..32b9cae39 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -961,6 +961,12 @@ void SrsSource::dispose() hls->dispose(); #endif + // cleaup the cached packets. + srs_freep(cache_metadata); + srs_freep(cache_sh_video); + srs_freep(cache_sh_audio); + + // cleanup the gop cache. gop_cache->dispose(); } diff --git a/trunk/src/core/srs_core_mem_watch.cpp b/trunk/src/core/srs_core_mem_watch.cpp index adfb69356..bbdcbc7bb 100644 --- a/trunk/src/core/srs_core_mem_watch.cpp +++ b/trunk/src/core/srs_core_mem_watch.cpp @@ -74,7 +74,7 @@ void srs_memory_report() std::map::iterator it; for (it = _srs_ptrs.begin(); it != _srs_ptrs.end(); ++it) { SrsMemoryObject* obj = it->second; - printf(" %s: %#"PRIx64", %dKB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size / 1000); + printf(" %s: %#"PRIx64", %dB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size); total += obj->size; } diff --git a/trunk/src/core/srs_core_performance.hpp b/trunk/src/core/srs_core_performance.hpp index 07a1e57af..c1b924756 100644 --- a/trunk/src/core/srs_core_performance.hpp +++ b/trunk/src/core/srs_core_performance.hpp @@ -192,8 +192,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * whether enable the special memory watcher. * which used for memory leak debug and hurts performance. */ -#undef SRS_MEM_WATCH #define SRS_MEM_WATCH +#undef SRS_MEM_WATCH #endif diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index fddd9702b..d0750f2fe 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -211,6 +211,11 @@ void check_macro_features() #warning "current branch is not stable, please use stable branch instead." srs_warn("SRS %s is not stable, please use stable branch %s instead", RTMP_SIG_SRS_VERSION, VERSION_STABLE_BRANCH); #endif + +#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 defined(SRS_AUTO_STREAM_CASTER) #warning "stream caster is experiment feature."