mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102)
1. Support detect memory leak by valgrind. 2. Free the http handler entry. 3. Free the stack of ST. --- Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
parent
ea7e2c2849
commit
7ab012c60f
18 changed files with 286 additions and 69 deletions
36
trunk/research/st/thread-join.cpp
Normal file
36
trunk/research/st/thread-join.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
g++ thread-join.cpp ../../objs/st/libst.a -g -O0 -o thread-join && ./thread-join
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../../objs/st/st.h"
|
||||
|
||||
void* pfn(void* arg) {
|
||||
printf("pid=%d, coroutine is ok\n", ::getpid());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
st_init();
|
||||
|
||||
printf("pid=%d, create coroutine #1\n", ::getpid());
|
||||
st_thread_t thread = st_thread_create(pfn, NULL, 1, 0);
|
||||
st_thread_join(thread, NULL);
|
||||
|
||||
st_usleep(100 * 1000);
|
||||
|
||||
printf("pid=%d, create coroutine #2\n", ::getpid());
|
||||
thread = st_thread_create(pfn, NULL, 1, 0);
|
||||
st_thread_join(thread, NULL);
|
||||
|
||||
st_usleep(100 * 1000);
|
||||
|
||||
printf("pid=%d, create coroutine #3\n", ::getpid());
|
||||
thread = st_thread_create(pfn, NULL, 1, 0);
|
||||
st_thread_join(thread, NULL);
|
||||
|
||||
printf("done\n");
|
||||
st_thread_exit(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue