mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Remove dead code: memory watch
This commit is contained in:
parent
0898a1a7ea
commit
4ef1acb700
11 changed files with 1 additions and 182 deletions
|
@ -50,7 +50,6 @@ using namespace std;
|
|||
#include <srs_app_rtsp.hpp>
|
||||
#include <srs_app_statistic.hpp>
|
||||
#include <srs_app_caster_flv.hpp>
|
||||
#include <srs_core_mem_watch.hpp>
|
||||
#include <srs_kernel_consts.hpp>
|
||||
#include <srs_app_coworkers.hpp>
|
||||
#include <srs_app_gb28181.hpp>
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <srs_core_mem_watch.hpp>
|
||||
|
||||
#ifdef SRS_MEM_WATCH
|
||||
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
using namespace std;
|
||||
|
||||
struct SrsMemoryObject
|
||||
{
|
||||
void* ptr;
|
||||
std::string category;
|
||||
int size;
|
||||
};
|
||||
|
||||
std::map<void*, SrsMemoryObject*> _srs_ptrs;
|
||||
|
||||
void srs_memory_watch(void* ptr, string category, int size)
|
||||
{
|
||||
SrsMemoryObject* obj = NULL;
|
||||
|
||||
std::map<void*, SrsMemoryObject*>::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<void*, SrsMemoryObject*>::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<void*, SrsMemoryObject*>::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
|
||||
|
|
@ -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 <srs_core.hpp>
|
||||
|
||||
#ifdef SRS_MEM_WATCH
|
||||
|
||||
#warning "MemoryWatch is deprecated."
|
||||
|
||||
#include <string>
|
||||
|
||||
// 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
|
||||
|
|
@ -38,7 +38,6 @@ using namespace std;
|
|||
#include <srs_kernel_file.hpp>
|
||||
#include <srs_kernel_codec.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_core_mem_watch.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue