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...
相关阅读
scala is leaving JVMJulia没戏了又开了个reactjs的项目,先来占个地方,慢慢更新。[bssd]Functional programming的一个好处lightroom请科普下双路deep learning聊点实际的,码农出货量。[bssd]教小孩计算机最难的地方...xeon phi就是翔啊如何run spark scala 代码,不用jar 的情况下?围棋人工智能Master只用了一个GPU(转)weidong, Jianxiong Xiao是你一个实验室?好牛啊lambda 和NLP之间有联系吗?scalding的学习资料好少啊!刚看到一个国内人做的花卉植物鉴别的app,叫“形色板上非科班的码农多吗以史为镜,可以知兴替。中国互联网,沧海桑田。 1、最早在美国上市的中国互联网公司是中华网,域名牛逼,中国概念,一度股价爆高到100多美元,后来一路跌到地板,然后退市,现在,谁还记得呢。 2、曾面试要求上机做题的,你们去不去面?Perl Q: how to convert integer to MAC addressscala vs clojure ?华人大妈谈deep learning的未来,大家怎么看? (转载)