[fpc-pascal] TGZFileStream.Destroy() does not close files?
dimitri shkermankov
dimitri.shkermankov at gmail.com
Wed Dec 23 19:44:05 CET 2015
Hi everyone!
I am currently working through an older codebase in FPC (2.6.4, exclusively
on Linux and x86_64 target) that I will have to maintain. My task is to fix
some bugs and make things more efficient if possible. Now, one program uses
TGZFileStream to read from a lot (say, 1000 or more files) one by one. In
the code, there is
[1] FStream := TGZFileStream.Create(FFileNames[i], gzOpenRead);
to open the files. When the stream ends and the next file is going to be
opened, there is
[2] FreeAndNil(FStream);
followed by another [1] with incremented i. The same FStream variable is
reused. But that should be no problem after FreeAndNil(), right? My problem
is that during the whole run time, file handles are never freed. At least
ls -l /proc/PID/fd
shows all files still open, and so does lsof.
Is that a bug in TGZFileStream or am I missing something? I think I can
provide a minimal working example, but maybe the question can be answered
without...
Thanks a lot, and best regards!
Dimitri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20151223/d8d0f886/attachment.html>
More information about the fpc-pascal
mailing list