dev.emsdn.com

Join About
Home SITEMAP Most Recent

Delphi

Home »» Delphi [Programming]
Thread Profile: memory leak in Delphi


memory leak in Delphi

Hi.
I used today a tool to check my app for memory leaks.
I've found 2 in my code and other 20-30 more in Delphi's code (Delphi 7.1).
They are not so big. The biggest is 4096 in System.pas. Should I close
my eyes and go on.
I mean the leaking in pretty small.
There is a second question: what happen with a leaking? It is that piece
of memory stored to the swap file or it stays forever in memory?
I know that Window 'downloads' the applications that are not used for a
while to swap to make some room in RAM.
Will be the leaked memory moved to swap also? In this case not even a
big leaking will be too harmful for the system's performances.
Delphi mailing list -Delphi (AT) elists (DOT) org


total 7 Comments Similar Thread
  • 7Answer
  • Total

at [2008-5-6 5:17:43]


Memory leak will stay until you the application exits.
I would assume it would also be swapped to disk because
S doesn't know what the application has done with it.
If a leak happens in a function that doesn't get called
very often, it is usually not too bad but if it happens
in a loop, you definitely want to fix it.


  • 1No.

at [2008-5-6 5:18:44]


Memory leaks in Delphi's code might not be memory leaks at all. They
might represent objects kept in memory for the life of the program that
use the side-effect of closing the program to free the associated
memory. I also use a similar technique for all kinds of global
(singleton) objects. I create them but never free them.

About leaked memory staying in memory or getting swaped to the hdd: The
S will normally swap memory to disk when it needs to allocate memory to
an application and it no longer has memory available. When in needs to
do that it will first try to swap out memory that hasn't been used for a
while - so truly leaked memory has a good chances of going down to the
HDD. Keep in mind that the S allocates memory in "pages", not "bytes" -
so your leaked memory might stay in memory because it shares page with
useful memory or as a side-affect of heap-management.

CubicDesign wrote:
Hi.

I used today a tool to check my app for memory leaks.

I've found 2 in my code and other 20-30 more in Delphi's code (Delphi 7.1).
They are not so big. The biggest is 4096 in System.pas. Should I close
my eyes and go on.
I mean the leaking in pretty small.

There is a second question: what happen with a leaking? It is that piece
of memory stored to the swap file or it stays forever in memory?
I know that Window 'downloads' the applications that are not used for a
while to swap to make some room in RAM.
Will be the leaked memory moved to swap also? In this case not even a
big leaking will be too harmful for the system's performances.

Delphi mailing list -Delphi (AT) elists (DOT) org

Delphi mailing list -Delphi (AT) elists (DOT) org


  • 2No.

at [2008-5-6 5:19:49]


>Memory leak will stay until you the application exits.

Do you mean that the leaked memory will exists until the application
that generated it is closed, the the leaked memory will be recovered?

Jack wrote:
I would assume it would also be swapped to disk because
S doesn't know what the application has done with it.
If a leak happens in a function that doesn't get called
very often, it is usually not too bad but if it happens
in a loop, you definitely want to fix it.

Delphi mailing list -Delphi (AT) elists (DOT) org


  • 3No.

at [2008-5-6 5:20:43]


It is not because a leak concern a memory allocated from a system.pas
function that it is a bug into Delphi code.
Could you tell use what are the leaks you've found ?

fyi: I'm using FastMM features to detect leaks in my Delphi 7 program and I
have no problem at all. All leaks found where my own fault.


  • 4No.

at [2008-5-6 5:21:53]


At 20:01 3/1/2007, CubicDesign wrote:
>Hi.
>
>I used today a tool to check my app for memory leaks.

Which tool?
Start Here to Find It Fast! -
$8.77 Domain Names -
Delphi mailing list -Delphi (AT) elists (DOT) org


  • 5No.

at [2008-5-6 5:22:52]


Do you mean that the leaked memory will exists until the application
that generated it is closed, the the leaked memory will be recovered?
That should be the case.
What is the tool that you used?
Delphi mailing list -Delphi (AT) elists (DOT) org


  • 6No.

at [2008-5-6 5:23:56]


The program was MemProof.

Jack wrote:
>Do you mean that the leaked memory will exists until the application
>that generated it is closed, the the leaked memory will be recovered?
>
>

That should be the case.

What is the tool that you used?

Delphi mailing list -Delphi (AT) elists (DOT) org

Delphi mailing list -Delphi (AT) elists (DOT) org


  • 7No.