Linux下内存检查
STL的一个好处就是省去自己管理内存的麻烦,但是我发现在Windows上用boundChecker检查内存时,总是会跟踪到stl的函数内部。最近在Linux下使用valgrind检查内存泄露又碰到这类问题。
比如:
23,416 bytes in 1 blocks are possibly lost in loss record 23 of 33
at 0x401AFE7: operator new(unsigned int) (vg_replace_malloc.c:214)
by 0x419F830: std::__default_alloc_template <true, 0>::_S_chunk_alloc(unsigned int, int&)
by 0x419F73C: std::__default_alloc_template <true, 0>::_S_refill(unsigned int) (in /usr/lib/libstdc++.so.5.0.3)
by 0x419F2AB: std::__default_alloc_template <true, 0>::allocate(unsigned int) (in /usr/lib/libstdc++.so.5.0.3)
by 0x41A52A7: std::string::_Rep::_S_create(unsigned int, std::allocator <char> const&) (in /usr/lib/libstdc++.so.5.0.3)
by 0x41A53D8: std::string::_Rep::_M_clone(std::allocator <char> const&, unsigned int) (in /usr/lib/libstdc++.so.5.0.3)
by 0x41A3145: std::string::reserve(unsigned int) (in /usr/lib/libstdc++.so.5.0.3)
by 0x41A36EB: std::string::append(unsigned int, char) (in /usr/lib/libstdc++.so.5.0.3)
by 0x41A33DE: std::string::operator+=(char) (in /usr/lib/libstdc++.so.5.0.3)
by 0x407C723: CMyclass::mymethod(std::istream&) (in /home/lzq/lib/libmylib.so)
最终的指向是std::__default_alloc_template <true, 0>::_S_chunk_alloc(unsigned int, int&) 函数当中调用new,最后又没有释放内存。
我不太了解的是这些内存泄露是否是
相关问答:
我们隶属中科院计算所网络重点实验室(http://www.ict.ac.cn/survey/channel/detail443.asp)基础设施课题组.
现因项目和业务拓展的需要,特需要招聘与项目相关的网络应用工程师1-2名。
具体要求如下。有意者 ......
while(1)
{
time_t now;
time(&now);
struct tm* pt=localtime(&now);
cout < < "当前时间" < < pt->t ......
linux初始化时把支持的物理内存都映射到page table中,之后进程需要内存时,也是映射到这个物理内存中,如此说来,linux初始化时创建的page table和进程中创建的page table指向同一块物理页面吗?这样做的目的是什么 ......
由于我才刚刚接触socket编程,自己写了一个简单程序,但就是在运行的时候出现段错误,无法解决,现在我把源代码贴出来,请各位大虾指正一下!谢谢!
#include<stdio.h>
#include<stdlib.h>
#include& ......