Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-08

TObjectList works; TFPObjectList gives memory leaks

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jim

Hi all,

Still working on my file indexer:
http://bitbucket.org/jb/flocate/changeset/6c6fa90e632e

Each search for files creates a TObjectList descendant (TDirectoryEntryList, see directoryentrylist.pp)

On finding a file, the search class createa a DirectoryEntry object with the relevant file properties and adds this to the directoryentrylist.

Finally, I iterate through the list and store the results in a database. Then I try to destroy the directoryentrylist, and the directoryentry items get deleted by the Tobjectlist code.

This works using a TObjectList; however when I use a TFPObjectList for TDirectoryEntryList, I have a memory leak of exactly all files/objects found that were not released.
(This is in FPC 2.5.1/Win32)

Am I missing something here? The documentation suggests that TObjectList and TFPObjectlist only differ in some notification stuff...

Thanks,

Regards, jb

Reply by email

Marco van de Voort
to Jim

In our previous episode, Jim said:

The question should be why tobjectlist works. Since you don't set the "freeobjects" anywhere.

Call inherited create(true) in your constructor instead of just create().

It would be interesting if you could come up with a little program that really shows the problem (e.g. a small program that changes behaviour if you just prefix "fp").

Reply by email

Jim
to Marco van de Voort
Marco van de Voort wrote 7 lines
In our previous episode, Marco van de Voort said: > > Call inherited create(true) in your constructor instead of just create(). Hmm no, that is not it either, since the constructor is overloaded. Then a small example program to test is really needed. If you can reproduce it, please file a bug at http://bugs.freepascal.org

True; I also explicitly set the ownsobject property. Nothing changed.

I'll try and see what I can do and file a bug if I have something working... (Of course, it could be my newb programming that's causing this, but then I'm extraordinarily lucky that tobjectlist works ;)

Regards, jb

Reply by email