1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Add api for tcmalloc

This commit is contained in:
winlin 2020-03-25 17:00:16 +08:00
parent 574ae58adc
commit 35a037cf05
8 changed files with 138 additions and 4 deletions

View file

@ -37,6 +37,10 @@ using namespace std;
#include <gperftools/profiler.h>
#endif
#ifdef SRS_AUTO_GPERF
#include <gperftools/malloc_extension.h>
#endif
#include <unistd.h>
using namespace std;
@ -185,6 +189,16 @@ srs_error_t do_main(int argc, char** argv)
// features
show_macro_features();
#ifdef SRS_AUTO_GPERF
// For tcmalloc, use slower release rate.
if (true) {
double trr = _srs_config->tcmalloc_release_rate();
double otrr = MallocExtension::instance()->GetMemoryReleaseRate();
MallocExtension::instance()->SetMemoryReleaseRate(trr);
srs_trace("tcmalloc: set release-rate %.2f=>%.2f", otrr, trr);
}
#endif
if ((err = run_directly_or_daemon()) != srs_success) {
return srs_error_wrap(err, "run");