: Hi,
: You all might know that we can easily find out which source code line has generated run time Access Violation using {$D+} directive and Search -> Find Error option.
: I would like to know whether any such easy way exists for finding memory leaks in Delphi5 or not? If so please let me know the detailed description.
:
: Bye.
:
There is one known memory leak in all programs using the VCL. This leak is located in the message to event conversion code, specifically in the message stub. Since this code is directly inaccessable by the programmer, you need search for it. Reference: Roy Nelson, "Memory Lost And Found... And Released", The Delphi Magazine Issue 75 (November 2001).
Other memory leaks can be prevented by correctly freeing resources and protecting code blocks with try...finally blocks. Since code can have many ways of allocating memory blocks, there are many ways of "creating" memory leaks. Since the compiler lacks the intelligence to assess all those ways, there is no way to find all memory leaks automatically. The only way to check for leaks is to do it manually.