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

Upgrade gperftools to 2.9 for GCP/GMC/GMP/GMD. (#2247)

This commit is contained in:
winlin 2021-12-12 15:38:30 +08:00
parent 63da0dca92
commit 44e9dc83e9
346 changed files with 169666 additions and 78 deletions

View file

@ -7,4 +7,4 @@ cpu_profiler: cpu_profiler.cc Makefile
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
-I../../../objs/gperf/include ../../../objs/gperf/lib/libtcmalloc_and_profiler.a -lpthread
clean:
rm -f cpu_profiler ./srs.prof*
rm -rf cpu_profiler ./srs.prof* ./*.dSYM

View file

@ -5,6 +5,6 @@ default: heap_checker
heap_checker: heap_checker.cc Makefile
g++ -o heap_checker heap_checker.cc -g -O0 -ansi \
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
../../../objs/gperf/lib/libtcmalloc_and_profiler.a -lpthread
-I../../../objs/gperf/include ../../../objs/gperf/lib/libtcmalloc_and_profiler.a -lpthread
clean:
rm -f heap_checker
rm -rf heap_checker ./*.dSYM

View file

@ -6,7 +6,7 @@
/**
@see: https://gperftools.github.io/gperftools/heap_checker.html
config srs with gperf(to make gperftools):
./configure --with-gperf --jobs=3
./configure --gperf=on --jobs=3
set the pprof path if not set:
export PPROF_PATH=`pwd`/../../../objs/pprof
to check mem leak:
@ -17,6 +17,8 @@ to check mem leak:
#include <signal.h>
#include <stdlib.h>
#include <gperftools/profiler.h>
void explicit_leak_imp() {
printf("func leak: do something...\n");
for (int i = 0; i < 1024; ++i) {
@ -63,7 +65,7 @@ int main(int argc, char** argv) {
if (!loop) {
return 0;
}
return 0;
}

View file

@ -0,0 +1,10 @@
.PHONY: default clean
default: heap_defense
heap_defense: heap_defense.cc Makefile
g++ -o heap_defense heap_defense.cc -g -O0 -ansi \
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
-I../../../objs/gperf/include ../../../objs/gperf/lib/libtcmalloc_debug.a -lpthread
clean:
rm -rf heap_defense ./*.dSYM

View file

@ -0,0 +1,30 @@
//
// Copyright (c) 2013-2021 Winlin
//
// SPDX-License-Identifier: MIT
//
/**
@see: https://blog.csdn.net/win_lin/article/details/50461709
config srs with gperf(to make gperftools):
./configure --gperf=on --gmd=on --jobs=3
to check mem corruption:
make && env TCMALLOC_PAGE_FENCE=1 ./heap_defense
*/
#include <stdio.h>
void foo(char* buf) {
buf[16] = 0x0f;
}
void bar(char* buf) {
printf("buf[15]=%#x\n", (unsigned char)buf[15]);
}
int main(int argc, char** argv) {
char* buf = new char[16];
foo(buf);
bar(buf);
return 0;
}

View file

@ -1,10 +1,10 @@
.PHONY: default clean
default: heap_checker
default: heap_profiler
heap_profiler: heap_profiler.cc Makefile
g++ -o heap_profiler heap_profiler.cc -g -O0 -ansi \
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
-I../../../objs/gperf/include ../../../objs/gperf/lib/libtcmalloc_and_profiler.a -lpthread
clean:
rm -f heap_profiler srs.*.heap
rm -f heap_profiler srs.*.heap ./*.dSYM

View file

@ -1,16 +0,0 @@
/**
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
*/
#include <unistd.h>
#include <string.h>
#include <stdio.h>
void foo(char* p){
memcpy(p, "01234567890abcdef", 16);
}
int main(int argc, char** argv){
char* p = new char[10];
foo(p);
printf("p=%s\n", p);
return 0;
}

View file

@ -1,16 +0,0 @@
/**
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
*/
#include <unistd.h>
#include <string.h>
#include <stdio.h>
void foo(char* p){
memcpy(p, "01234567890abcdef", 16);
}
int main(int argc, char** argv){
char* p = new char[10];
foo(p);
printf("p=%s\n", p);
return 0;
}