Redian新闻
>
有什么工具可以检查内存泄漏么
avatar
有什么工具可以检查内存泄漏么# Programming - 葵花宝典
t*l
1
每次都是内存出问题,都不知道去哪里找,郁闷
avatar
z*y
2
valgrind for linux

【在 t*****l 的大作中提到】
: 每次都是内存出问题,都不知道去哪里找,郁闷
avatar
n*g
3
找人帮你代码走读
点出你的不良习惯

【在 t*****l 的大作中提到】
: 每次都是内存出问题,都不知道去哪里找,郁闷
avatar
n*g
4
pc-lint可以,其实有很多静态代码检查工具的。不过要钱的。

【在 t*****l 的大作中提到】
: 每次都是内存出问题,都不知道去哪里找,郁闷
avatar
D*s
5
like purify

【在 n****g 的大作中提到】
: pc-lint可以,其实有很多静态代码检查工具的。不过要钱的。
avatar
r*q
6
Carefully use C++ and you can almost have NO memory/resource leack,
memory overrun. And you do almost NOTHING in your daily programming
by achieving this aim.
I really don't understand why so many people have memory problem...

【在 t*****l 的大作中提到】
: 每次都是内存出问题,都不知道去哪里找,郁闷
avatar
t*l
7
.NET底下有些函数可以用来检查内存泄漏
花了几个小时,看了帮助文档,总算学会了
不查不知道,一查吓一跳,存在泄漏的地方比我想象得要多得多
一条一条改过来了。
哎,还是自己编程习惯太不好了,怎么才能改变呢?

【在 n****g 的大作中提到】
: pc-lint可以,其实有很多静态代码检查工具的。不过要钱的。
avatar
r*q
8
对于C++来说,一条就够了:不用"裸"的new。对内存以外的资源也适合。
只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
不会发生,或者说一旦发生可以检测出来。
在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
C++提供了很多优秀的特性,但很多人却用得很垃圾...

【在 t*****l 的大作中提到】
: .NET底下有些函数可以用来检查内存泄漏
: 花了几个小时,看了帮助文档,总算学会了
: 不查不知道,一查吓一跳,存在泄漏的地方比我想象得要多得多
: 一条一条改过来了。
: 哎,还是自己编程习惯太不好了,怎么才能改变呢?

avatar
u*u
9
很多测的都不准的,不能全信
avatar
c*e
10
i take it like a joke.
maybe it can be done, but for pretty much all mid and up scale project,
none of them ended up like that. u always have to put extra brain to think
about mems all the time. at least for realtime networking stuff, thats my
feeling.
I dont want to use smart/auto ptr at all.
avatar
a*a
11
完全赞同。本来想说两句的,看见有人已经说了,我就省得麻烦。

【在 r*******q 的大作中提到】
: 对于C++来说,一条就够了:不用"裸"的new。对内存以外的资源也适合。
: 只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
: 不会发生,或者说一旦发生可以检测出来。
: 在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
: 函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
: 你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
: 检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
: C++提供了很多优秀的特性,但很多人却用得很垃圾...

avatar
N*n
12
Purify

【在 t*****l 的大作中提到】
: 每次都是内存出问题,都不知道去哪里找,郁闷
avatar
u*u
13
关键是预防,而不是检查。

【在 a**a 的大作中提到】
: 完全赞同。本来想说两句的,看见有人已经说了,我就省得麻烦。
avatar
r*q
14
You know nothing about what I'm saying...
There is NO smart/auto ptr in standard C++ at all.
And I completely disagree your statement.
At lease for memory leak, only constructor, destructor and operator overload
are needed. It can be adapt to ANY size of project. You NEVER need
to consder memory leak.

【在 c********e 的大作中提到】
: i take it like a joke.
: maybe it can be done, but for pretty much all mid and up scale project,
: none of them ended up like that. u always have to put extra brain to think
: about mems all the time. at least for realtime networking stuff, thats my
: feeling.
: I dont want to use smart/auto ptr at all.

avatar
r*q
15
Please, think, then try. Don't expect others can give you
the details. If you can't get the solution from coarse
information, you are not a good programmer. You should
feel luck that you already have some coarse information.
I have to figure it out myself...
avatar
w*r
16
Smart Pointers and Naked Pointers:
http://www.developer.com/tech/print.php/10923_3491166_3

【在 r*******q 的大作中提到】
: Please, think, then try. Don't expect others can give you
: the details. If you can't get the solution from coarse
: information, you are not a good programmer. You should
: feel luck that you already have some coarse information.
: I have to figure it out myself...

avatar
r*q
17
NEVER use such stupid "smart" thing. You ONLY need standard,
most simple C++ syntax!
It's M$'s style to introduce those "smart" things
and make everything messed up.
The so called "smart" pointer is something like COM.
But COM is the worst thing M$ introduced!
Anything need to call "Release()" is NOT the solution.
The only correct way should let you totaly FORGET
Release() or delete completely.

【在 w********r 的大作中提到】
: Smart Pointers and Naked Pointers:
: http://www.developer.com/tech/print.php/10923_3491166_3

avatar
q*c
18
That is .NET.
But even .NET has tons of problem at release shared resources.
There is no magica bullet. Can not believe what you said.
can kindly give us a little example how to "completely eliminate"
leak? This can help too many people.

【在 r*******q 的大作中提到】
: NEVER use such stupid "smart" thing. You ONLY need standard,
: most simple C++ syntax!
: It's M$'s style to introduce those "smart" things
: and make everything messed up.
: The so called "smart" pointer is something like COM.
: But COM is the worst thing M$ introduced!
: Anything need to call "Release()" is NOT the solution.
: The only correct way should let you totaly FORGET
: Release() or delete completely.

avatar
f*e
19

Totally agree. You have to know when to release the resources, don't you?
For a complicated system that you need to pass things around, some bookkeeping
have to be done.

【在 q*c 的大作中提到】
: That is .NET.
: But even .NET has tons of problem at release shared resources.
: There is no magica bullet. Can not believe what you said.
: can kindly give us a little example how to "completely eliminate"
: leak? This can help too many people.

avatar
c*e
20
wow, i might know nothing so please let me know something. some solid example
will be nice indeed.
btw auto_ptr is part of C++ for many many years already

【在 r*******q 的大作中提到】
: You know nothing about what I'm saying...
: There is NO smart/auto ptr in standard C++ at all.
: And I completely disagree your statement.
: At lease for memory leak, only constructor, destructor and operator overload
: are needed. It can be adapt to ANY size of project. You NEVER need
: to consder memory leak.

avatar
w*r
21

Read it through, no "release()" needed.
The smart ptr example shows how it can be done, do not take it literally.
Automatic resource management of course can be done. This is not rocket
science,
see Java. But it is at the cost of performance: for example, with overloaded
assignment operator a single ptr assignment instruction is now replaced with
several bookkeeping instructions, which means it is now several times slower.
If you can show me your clever way of achieving auto res mgmt with good

【在 r*******q 的大作中提到】
: NEVER use such stupid "smart" thing. You ONLY need standard,
: most simple C++ syntax!
: It's M$'s style to introduce those "smart" things
: and make everything messed up.
: The so called "smart" pointer is something like COM.
: But COM is the worst thing M$ introduced!
: Anything need to call "Release()" is NOT the solution.
: The only correct way should let you totaly FORGET
: Release() or delete completely.

avatar
N*n
22

If there really exists a robust & efficient way of getting rid of
memory leak then no one would bother researching so much on garbage
collection. Before I see some detail explanation on how you do it,
I'd remain skeptical about what you said.

【在 r*******q 的大作中提到】
: Please, think, then try. Don't expect others can give you
: the details. If you can't get the solution from coarse
: information, you are not a good programmer. You should
: feel luck that you already have some coarse information.
: I have to figure it out myself...

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