r*q
8 楼
对于C++来说,一条就够了:不用"裸"的new。对内存以外的资源也适合。
只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
不会发生,或者说一旦发生可以检测出来。
在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
C++提供了很多优秀的特性,但很多人却用得很垃圾...
【在 t*****l 的大作中提到】
: .NET底下有些函数可以用来检查内存泄漏
: 花了几个小时,看了帮助文档,总算学会了
: 不查不知道,一查吓一跳,存在泄漏的地方比我想象得要多得多
: 一条一条改过来了。
: 哎,还是自己编程习惯太不好了,怎么才能改变呢?
只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
不会发生,或者说一旦发生可以检测出来。
在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
C++提供了很多优秀的特性,但很多人却用得很垃圾...
【在 t*****l 的大作中提到】
: .NET底下有些函数可以用来检查内存泄漏
: 花了几个小时,看了帮助文档,总算学会了
: 不查不知道,一查吓一跳,存在泄漏的地方比我想象得要多得多
: 一条一条改过来了。
: 哎,还是自己编程习惯太不好了,怎么才能改变呢?
u*u
9 楼
很多测的都不准的,不能全信
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.
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.
a*a
11 楼
完全赞同。本来想说两句的,看见有人已经说了,我就省得麻烦。
【在 r*******q 的大作中提到】
: 对于C++来说,一条就够了:不用"裸"的new。对内存以外的资源也适合。
: 只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
: 不会发生,或者说一旦发生可以检测出来。
: 在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
: 函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
: 你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
: 检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
: C++提供了很多优秀的特性,但很多人却用得很垃圾...
【在 r*******q 的大作中提到】
: 对于C++来说,一条就够了:不用"裸"的new。对内存以外的资源也适合。
: 只要做到了这一条,你一般来说是不会有内存泄漏问题的,内存溢出也基本上
: 不会发生,或者说一旦发生可以检测出来。
: 在积累一定代码后,在你的C++程序中应该是看不到new/delete和其它内存分配
: 函数的。而且你的C++程序和没有这些积累的代码几乎没有区别。更重要的是
: 你不需要老是记着去调用delete。你完全可以把delete忘了。你根本不需要什么
: 检测内存泄漏的软件,因为出现泄漏的概论几乎为0.
: C++提供了很多优秀的特性,但很多人却用得很垃圾...
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.
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.
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...
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...
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...
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...
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
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
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.
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.
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.
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.
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.
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.
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...
相关阅读
做大项目的话,有两个语言features是杀手人类比较two的事情akka能和C++程序通信吗?Testing DropzoneJS uploading files with capybara珍惜生命,远离 R 和 Go用R抓网页突然就动不了了Node.js 为什么升级这么快machine learning搞多了会怀疑自己的独立思维服务器端纯的asio的异步怎么写?fp适合小孩学ClassName.this请教大牛, 大家为什么不用jsp了留学党颤抖吧,老衲破了 Priceline (转载)谁有AWS Product Advertising API经验的?angular 2怎么跑?test《糖果粉碎传奇》真的“粉碎”了C++11使用感受及一些问题Node child process的spawn的 command argument怎么用variable ?Re: 北大老二不要吹自己多厉害,上个视频看看 (转载)