- 论坛徽章:
- 0
|
- int main()
- {
- //sigset_t sign;
- //sigemptyset(&sign);
- //sigaddset(&sign, SIGINT);
- //sigprocmask(SIG_SETMASK,&sign,NULL);
- //struct sigaction siga;
- //siga.sa_handler = SIG_DFL;
- //siga.sa_mask = sign;
- //siga.sa_flags = SA_ONESHOT|SA_NOMASK;
- //siga.sa_restorer = NULL;
- //sigaction(SIGINT, &siga, NULL);
- //Timer::initTimer();
- trace tr;
- trace2 tr2;
- //Timer::getSingletionPtr()->setTimer(1,SubscriberHelper(&tr, &trace::output),5);
- //Timer::getSingletionPtr()->setTimer(2,SubscriberHelper(&tr2, &trace2::output2),1);
- //sleep(10);
- //Timer::releaseTimer();
- std::map<int,int> mymap;
- mymap.insert(std::make_pair(3,3));
- mymap.clear();
- return 0;
- }
复制代码 代码如上, 用valgrind 做内存泄漏测试时如果如下
valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./testApp
==20974== 960 bytes in 1 blocks are still reachable in loss record 1 of 1
==20974== at 0x4004790: operator new(unsigned) (vg_replace_malloc.c:164)
==20974== by 0x40E9BA0: std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned, int& (in /usr/lib/libstdc++.so.5.0.7)
==20974== by 0x40E9AAC: std::__default_alloc_template<true, 0>::_S_refill(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==20974== by 0x40E9687: std::__default_alloc_template<true, 0>::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==20974== by 0x804931B: std::__simple_alloc<std::_Rb_tree_node<std::pair<int const, int> >, std::__default_alloc_template<true, 0> >::allocate(unsigned) (stl_alloc.h:23
==20974== by 0x80491EF: std::_Rb_tree_alloc_base<std::pair<int const, int>, std::allocator<std::pair<int const, int> >, true>::_M_get_node() (stl_tree.h:564)
==20974== by 0x8048E01: std::_Rb_tree_base<std::pair<int const, int>, std::allocator<std::pair<int const, int> > >::_Rb_tree_base(std::allocator<std::pair<int const, int> > const& (stl_tree.h:579)
==20974== by 0x8048B1C: std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree(std::less<int> const&, std::allocator<std::pair<int const, int> > const& (stl_tree.h:730)
==20974== by 0x8048A3E: std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >::map() (stl_map.h:124)
==20974== by 0x8048988: main (main.cpp:52)
==20974==
==20974== LEAK SUMMARY:
==20974== definitely lost: 0 bytes in 0 blocks.
==20974== possibly lost: 0 bytes in 0 blocks.
==20974== still reachable: 960 bytes in 1 blocks.
==20974== suppressed: 0 bytes in 0 blocks.
这里的 still reachable 的960字节是代表泄漏吗? |
|