Board index » cppbuilder » Weird 'memory leak' symptoms

Weird 'memory leak' symptoms

Ok, here is a problem that has hounded me for literally years now and
I can't make any sense of it...

I have an app where I use ImageList-based dragging to move things
around visually. I have a subclassed TGraphicControl that calls
TControl.BeginDrag() at the appropriate times and assigns a custom
ImageList as needed when dragging starts.

On most machines this seems to work fine. The app can be run for hours
and hours and the memory usage stays steady.

On some systems (with S3 and some NVidia video cards), each time the
dragging occurs the Windows Task Manager reports a memory increase for
the app. The increase comes in BIG chunks if running a 32-bit color
model. Eventually, the app will consume all physical memory and things
of course get bad from there (including the "Canvas does not allow
drawing" fun, etc.)

I have investigated my code and I can find NO memory leak anywhere.
And it doesn't make sense that the memory leak would only occur only
with some systems (i.e. video cards) and not others if the problem is
actually in MY code.

Furthermore, with the S3 Trio card I have here to test, if I minimize
and restore the app the excessive memory usage is cleared!!! What the
heck could mimizing and restoring the window have to do with the
memory allocation?

Is this some weird video driver bug with old S3 drivers and some of
the newer NVidia cards? Is it some Delphi-resource-caching thingy that
I can prevent (and if so why would it be video-card dependent)? This
is costing me sales... Has anyone else seen something similar with
ImageList-based dragging?

---
Michael McCulloch

 

Re:Weird 'memory leak' symptoms


I don't have the answer to your problem, but I'll tell you something similar
I've observed in case it helps you figure yours out.

When I have a database connection to Interbase and do a bunch of processing
the IBServer processing memory grows (in Task View, Processes). It keeps
growing until I actually close the DB connection to the server and reopen
it. At the point I close and reopen, IBServer memory is freed and starts
growing again.

I have a program that loads a 2.5 mb text file for internal processing. I
load the file into a TStringList, at which point, the Task View shows the
memory increasing about 7 MB. This extra memory remains in Task View until I
minimize the form and then restore it. After restoring the form, the extra
memory is not displayed in Task View, and never does reappear there even
though the program uses this loaded text file for the duration of the
program.

When I am drawing on a canvas that has not been assigned to a form canvas, I
get the "Canvas does not allow drawing" error. When I use a TMetafileCanvas,
that has not been created with a TMetafile that has not had memory newly
reallocated for it (in other words, using a preexisting metafile that has
already been used with another TMetafile Canvas), I get the same error.

Good luck,

Kevin Berry

Other Threads