About memory leak detection. | | |
Hi, all
I really interested in how to check the memory leak of a program.
Your smart guys, do you have excellent ideas that could share with me?
Thank you.
The following is my idea:
In C programming language, there's a "malloc", there must a "free",
my solution of the detection of leak is, find the corresponding "free"
of "malloc". This the first condition.
Another one is much more difficult, the lost of a pointer. I think,
once a pointer is defined, it should be registered. Any operations on
pointer, like assigned or "free", all the operation must be recorded!
So, we can find the lost of pointer and return to programmers.
This is code-based detection.
Application-based detection needs asm knowledge, I will try it then.
Need your comments and advice. Thank you! | | | | re: About memory leak detection.
mosaic <mosaic@hotmail.com> wrote:
[color=blue]
> In C programming language, there's a "malloc", there must a "free",
> my solution of the detection of leak is, find the corresponding "free"
> of "malloc". This the first condition.[/color]
This is also impossible to do outside the running program. No other
instance can possibly determine with any reliability which individual
malloc()ed block a given call of free() will actually act upon.
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain. | | | | re: About memory leak detection.
In 'comp.lang.c', mosaic <mosaic@hotmail.com> wrote:
[color=blue]
> Hi, all
> I really interested in how to check the memory leak of a program.
> Your smart guys, do you have excellent ideas that could share with me?
> Thank you.
>
> The following is my idea:
>
> In C programming language, there's a "malloc", there must a "free",[/color]
Real-life is not that simple. It may have calloc(), and more tricky(),
realloc() !
[color=blue]
> my solution of the detection of leak is, find the corresponding "free"
> of "malloc". This the first condition.
>
> Another one is much more difficult, the lost of a pointer. I think,
> once a pointer is defined, it should be registered. Any operations on
> pointer, like assigned or "free", all the operation must be recorded!
> So, we can find the lost of pointer and return to programmers.
>
> This is code-based detection.
>
> Application-based detection needs asm knowledge, I will try it then.[/color]
FYI (drop me an email if you are stuck): http://mapage.noos.fr/emdel/sysalloc_um.htm http://mapage.noos.fr/emdel/clib/ed/inc/SYSALLOC.H http://mapage.noos.fr/emdel/clib/ed/src/SYSALLOC.C
Missing stuffs at: http://mapage.noos.fr/emdel/clib.htm
--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/ | | | | re: About memory leak detection.
In <cd5tsp$uql$1@mail.cn99.com> mosaic <mosaic@hotmail.com> writes:
[color=blue]
> I really interested in how to check the memory leak of a program.[/color]
For starters, use one of the many debugging malloc implementations
available that also includes memory leak detection. Choose one coming
with source code, so that you can see how it is done. See the FAQ or
google yourself.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de | | | | re: About memory leak detection.
On Thu, 15 Jul 2004 20:37:26 +0800, mosaic wrote:
[color=blue]
> Hi, all
> I really interested in how to check the memory leak of a program.
> Your smart guys, do you have excellent ideas that could share with me?
> Thank you.
>
> The following is my idea:
>
> In C programming language, there's a "malloc", there must a "free",
> my solution of the detection of leak is, find the corresponding "free"
> of "malloc". This the first condition.
>
> Another one is much more difficult, the lost of a pointer. I think,
> once a pointer is defined, it should be registered. Any operations on
> pointer, like assigned or "free", all the operation must be recorded!
> So, we can find the lost of pointer and return to programmers.
>
> This is code-based detection.
>
> Application-based detection needs asm knowledge, I will try it then.
>
> Need your comments and advice. Thank you![/color]
The "Standford Checker" already has a lot going when it comes to C source
code analyzis, there are probably some interresting papers. http://metacomp.stanford.edu/
(or for something similar; http://smatch.sourceforge.net/) | | | | re: About memory leak detection.
mosaic wrote:[color=blue]
> Hi, all
> I really interested in how to check the memory leak of a program.
> Your smart guys, do you have excellent ideas that could share with me?
> Thank you.
>
> The following is my idea:
>
> In C programming language, there's a "malloc", there must a "free",
> my solution of the detection of leak is, find the corresponding "free"
> of "malloc". This the first condition.
>
> Another one is much more difficult, the lost of a pointer. I think,
> once a pointer is defined, it should be registered. Any operations on
> pointer, like assigned or "free", all the operation must be recorded!
> So, we can find the lost of pointer and return to programmers.
>
> This is code-based detection.
>
> Application-based detection needs asm knowledge, I will try it then.[/color]
Well - the whole idea of memory detection is tied closely to the
implementation. For eg, one memory leak detector that i could think is
the mtrace utility . http://www.gnu.org/software/libc/man...on%20Debugging.
This one is really good, but as i said before, works only where you
have glibc implementation .
HTH .
--
Karthik. | | | | re: About memory leak detection.
Nils O. SelÃ¥sdal åé:[color=blue]
> On Thu, 15 Jul 2004 20:37:26 +0800, mosaic wrote:
>
>[color=green]
>>Hi, all
>> I really interested in how to check the memory leak of a program.
>>Your smart guys, do you have excellent ideas that could share with me?
>> Thank you.
>>
>>The following is my idea:
>>
>> In C programming language, there's a "malloc", there must a "free",
>>my solution of the detection of leak is, find the corresponding "free"
>>of "malloc". This the first condition.
>>
>> Another one is much more difficult, the lost of a pointer. I think,
>>once a pointer is defined, it should be registered. Any operations on
>>pointer, like assigned or "free", all the operation must be recorded!
>>So, we can find the lost of pointer and return to programmers.
>>
>> This is code-based detection.
>>
>>Application-based detection needs asm knowledge, I will try it then.
>>
>> Need your comments and advice. Thank you![/color]
>
> The "Standford Checker" already has a lot going when it comes to C source
> code analyzis, there are probably some interresting papers.
> http://metacomp.stanford.edu/
>
> (or for something similar; http://smatch.sourceforge.net/)[/color]
Thank you very much for your kind suggestiones. I will try to hack the
papers and work on my own code.
And, thank you all. | | | | re: About memory leak detection.
mosaic wrote:
[color=blue]
> Hi, all
> I really interested in how to check the memory leak of a program.
> Your smart guys, do you have excellent ideas that could share with me?
> Thank you.
>
> The following is my idea:
>
> In C programming language, there's a "malloc", there must a "free",
> my solution of the detection of leak is, find the corresponding "free"
> of "malloc". This the first condition.
>
> Another one is much more difficult, the lost of a pointer. I think,
> once a pointer is defined, it should be registered. Any operations on
> pointer, like assigned or "free", all the operation must be recorded!
> So, we can find the lost of pointer and return to programmers.
>
> This is code-based detection.
>
> Application-based detection needs asm knowledge, I will try it then.
>
> Need your comments and advice. Thank you![/color]
There exist a lot of Tools doing the job for you, but unfortunatly they
are not for free (BoundsChecker is a very good one, I work with, but it
is expensive ~1000 ?).
If you work with Dev C++ from MS they have a lot of Debugging-Macros,
which are very usefull. Search for 'memory leaks' and you will get a lot
of useful hints.
best regards
Bernhard |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,533 network members.
|