だから私は誰かが光を当てることができることを望んでいるという奇妙な問題を抱えています...私は次のコードを持っています:
#include <unistd.h>
#include <mcheck.h>
#include <pthread.h>
static void *run(void *args)
{
sleep(1);
return NULL;
}
int main()
{
mtrace();
pthread_t thread;
pthread_create(&thread, NULL, run, NULL);
pthread_join(thread, NULL);
return 0;
}
そして、私はこれらの2つの方法でコンパイルしました:
g++ -static program.cpp -lpthread
と
g++ program.cpp -ltpthread
mtrace の出力 (私の場合は mem.out) を見ると、
-static
オプションのmtrace
レポートを使用すると、次のように表示されます。
Memory Not freed:
__________________
Address Size Caller
0x085ac350 0x88 program.cpp:0
しかし、-static
オプションを除外するmtrace
と、輝かしいことが報告されます。
No memory leaks.
ここで何が起こっているかについてのアイデアはありますか?