avatar
how to detect memory leak# JobHunting - 待字闺中
s*n
1
这个问题怎么回答?网上没有找到满意的资料。请指点
avatar
b*8
2
有第三方软件检测的,不知道啥原理,估计就是直接观测内存。
avatar
g*s
3
好像也可以自己overload new和delete to include some associative information,
比如用一个变量记录内存分配状况, 每次new 变量累加,每次delete变量递减。 最后
观察此变量是不是0就知道有没有leak了。
avatar
g*s
4
the idea is too simple.
what if i new an array with 10 elements, and delete elements one by one?

【在 g*******s 的大作中提到】
: 好像也可以自己overload new和delete to include some associative information,
: 比如用一个变量记录内存分配状况, 每次new 变量累加,每次delete变量递减。 最后
: 观察此变量是不是0就知道有没有leak了。

avatar
g*e
5
new an array with 10 elements should call the constructor 10 times.
So the variable should increase by 10 if you do it right in the constructor.

【在 g*********s 的大作中提到】
: the idea is too simple.
: what if i new an array with 10 elements, and delete elements one by one?

avatar
s*n
6
new一个数据需要call 10此构造函数?给个代码例子看看?多谢

constructor.

【在 g******e 的大作中提到】
: new an array with 10 elements should call the constructor 10 times.
: So the variable should increase by 10 if you do it right in the constructor.

avatar
J*n
8
回答用valgrind可不可以?
avatar
w*g
9
应该可以,memory leak detection是个专业的东西,深究起来很多内容,学用
valgrind,继之基本原理就不错了,毕竟工程中间没人让你去钻那么深,能用工具照出
来就不错。也要看问你的人的目的,如果是专业memory leak detection的工具开发,
你当然需要知道很多原理怎么做。

【在 J*********n 的大作中提到】
: 回答用valgrind可不可以?
avatar
r*3
10
valgrind
avatar
r*3
11
如果我是面试,能够回答出这个词,足够了。

【在 J*********n 的大作中提到】
: 回答用valgrind可不可以?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。