|
|
what is "memory leak"?
|
|
|
|
|
Re: what is "memory leak"?
|
|
An error in a program's dynamic-store allocation logic that causes it to fail to reclaim discarded memory, leading to eventual collapse due to
memory exhaustion. Also (esp. at CMU) called core leak. These problems were severe on older machines with small, fixed-size address spaces, and
special "leak detection" tools were commonly written to root them out. With the advent of virtual memory, it is unfortunately easier to be sloppy about
wasting a bit of memory (although when you run out of memory on a VM machine, it means you've got a real leak!). See aliasing bug, fandango on
core, smash the stack, precedence lossage, overrun screw, leaky heap, leak.
-- http://www.antionline.com/features/jargon/memoryleak.html
EJ
-------------------------
There's no spoon
- The Matrix
-------------------------
|
|
|
Re: what is "memory leak"?
|
|
内存泄漏。
这样的程序运行时间长了会导致系统崩溃的。
|
|
|
Re: what is "memory leak"?
|
|
Could you give me some example?
what should I pay attention to in my programs?
|
|
|
Re: what is "memory leak"?
|
|
Because all dynamically allocation memory of every process will be freed when that process is exiting, "memory leak" can be a big concern when you are coding shell, daemon program or kernel module, because they are supposed to be running for relatively long time, and may run under root level provilidge.
A "memory leak" problem is a bug in your program, some special logic under special circumstance causes it happen quitely, it's so hard for me to program a typical "memory leak" program intentionly, just as same as to code a typical bug.
EJ
-------------------------
There's no spoon
- The Matrix
-------------------------
|
|
|
Re: what is "memory leak"?
|
|
If I malloc a block of memory, then exit but forget to free it , will "memory leak '' be happened at last?
|
|
|
Re: what is "memory leak"?
|
|
No, kernel will free them for you.
EJ
-------------------------
There's no spoon
- The Matrix
-------------------------
|
|
|
Re: what is "memory leak"?
|
|
No,of course.because u exit.
下岗了,救命啊(我可说的是真的)!
|
|
|
When will the "memory leak" happen?
|
|
I am still confused !
Ok, let's suppose:
my program is still running, it maybe last for a long period but I don't know, I malloc a block of memory, and forget to free it, that means this block of memory are used, so these unreleased memory grow and grow ,
then "memory leak" happen.
Is it right?
|
|
|
Re: When will the "memory leak" happen?
|
|
y.
下岗了,救命啊(我可说的是真的)!
|
|
|
Any tools to find "memory leak" on linux?
|
|
I see!
Thanks all of you !
|
|
|
Re: When will the "memory leak" happen?
|
|
It won't be a problem, if you just malloc a block of memory once, and never free it. The real "memory leak" problem is that some time your process makes a mistake that cause the allocated memory cannot be freed, but you don't know.
Let's make a example here:
char *p, *q;
for (;;) {
p = malloc(1024);
q = malloc(1024);
...
p = q;
free(p);
}
This is a typical "memory leak".
EJ
-------------------------
There's no spoon
- The Matrix
-------------------------
|