根本不重要 - 内存泄漏 [英] not important at all - memory leak
问题描述
嘿,
这与绝对没有任何关系,除了我的好奇之外没有任何重要的价值。
有没有人有一个特别棘手的内存泄漏的例子
很难发现。我想看到一些有点不寻常的东西
或模糊不清。关于
功能X或场景X的一些深入知识,会导致内存泄漏。什么东西
很容易错过。
这只是为了好奇而已。如果有人有一个小代码snippit或者例子我很想看到它
欢呼
G
Hey,
this is related to absolutely nothing in particular and is of no
importance whatsoever except for my curiousity.
Does anybody have an example of a particularly tricky memory leak
that''s hard to spot. I''d like to see something that''s a little unusual
or obscure. something that involves some in depth knowledge about
functionality X or scenario X and that causes a memory leak. Something
that would be really easy to miss.
This is simply for curiousity sake and nothing more. if anybody has a
little code snippit or example I''d love to see it
cheers
G
推荐答案
Gr **** *@nospam.com 写道:
嘿,
这与绝对没什么特别相关,除了我的重要性之外没什么重要的好奇。
有没有人有一个特别棘手的内存泄漏的例子,这很难被发现。我想看到一些有点不寻常的东西或模糊不清的东西。涉及到有关功能X或方案X的深入知识并导致内存泄漏的内容。很容易错过的东西。
这只是为了好奇而已。如果有人有一个小代码snippit或者例子我很想看到它
欢呼
G
Hey,
this is related to absolutely nothing in particular and is of no
importance whatsoever except for my curiousity.
Does anybody have an example of a particularly tricky memory leak
that''s hard to spot. I''d like to see something that''s a little unusual
or obscure. something that involves some in depth knowledge about
functionality X or scenario X and that causes a memory leak. Something
that would be really easy to miss.
This is simply for curiousity sake and nothing more. if anybody has a
little code snippit or example I''d love to see it
cheers
G
>
混合分配器与错误的解除分配器很容易错过。 (new []
with delete),(new with delete []),(new with free)等....
示例:
int * i = new int(123); //这不会创建数组
delete [] i; //错误的deallocator
Mixing allocators with wrong deallocators can be easy to miss. (new[]
with delete), (new with delete[]), (new with free), etc....
Example:
int *i = new int(123); //This does NOT create an array
delete[] i; //Wrong deallocator
谢谢,开始不错。我会发现那一个。我正在追逐一个人我不会发现......这是一个非常棘手的问题。谢谢,我是
编译列表。
基类中的
(非)虚拟析构函数是一个很好的,我已经有了
那个。
其他任何人......没有磨机的东西。
欢呼
格雷厄姆
thanks, nice start. I would have spotted that one. I''m after one I
would NOT have spotted.... a really tricky one. Thanks though, I''m
compiling a list.
(non) virtual destructors in base classes is a good one, I already have
that.
any others...not run of the mill stuff.
cheers
Graham
Gr ***** @ nospam。 com 写道:
嘿,
这与绝对没有任何关系,除了我的好奇之外没有任何重要性。
有没有人有一个特别棘手的内存泄漏的例子,这很难被发现。我想看到一些有点不寻常的东西或模糊不清的东西。涉及到有关功能X或方案X的深入知识并导致内存泄漏的内容。很容易错过的东西。
这只是为了好奇而已。如果有人有一个小代码snippit或者例子我很乐意看到它
Hey,
this is related to absolutely nothing in particular and is of no
importance whatsoever except for my curiousity.
Does anybody have an example of a particularly tricky memory leak
that''s hard to spot. I''d like to see something that''s a little unusual
or obscure. something that involves some in depth knowledge about
functionality X or scenario X and that causes a memory leak. Something
that would be really easy to miss.
This is simply for curiousity sake and nothing more. if anybody has a
little code snippit or example I''d love to see it
好吧,ADL可以默默地改变函数调用的含义:
命名空间N
{
class C {};
void f (C c,int i)
{
//删除东西
}
}
int main()
{
N :: C c;
f(c,1.0); //可以给出转换警告
}
添加全局函数
void f(C c, double d);
更改f()调用的含义。如果N :: f()负责
删除内容,你可能会感到惊讶。
Jonathan
Well, ADL can change the meaning of a function call silently:
namespace N
{
class C{};
void f(C c, int i)
{
// deletes things
}
}
int main()
{
N::C c;
f(c, 1.0); // may give a conversion warning
}
Adding the global function
void f(C c, double d);
changes the meaning of the call to f(). If N::f() was in charge of
deleting things, you may be suprised.
Jonathan
这篇关于根本不重要 - 内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!