[fpc-pascal] FindFirst...FindClose

fpclist at silvermono.co.za fpclist at silvermono.co.za
Mon May 18 18:41:40 CEST 2009


I must agree with Michael.

In my experience, it doesn't matter where the findclose() is placed, as long 
as it's called within the scope of the findfirst(), findnext(). If 
findclose() is not called, all that happens is that the OS will use up file 
handles, which are finite in quantity on any given system.

If you're using Delphi or FPC in MS Windows, fire up Task Manager, check 
the "Handles" column within the "processes" tab in task manager to see if 
handles are being "lost" from within your app.

BTW, Task manager is a simple debugging "tool" that helps identify how your 
app is doing with regards to a range of resources, memory, etc. I also use 
KDE System Guard when coding for Linux. 

:=Nino

//*****************************************************************************************************

On Monday 18 May 2009 17:25:51 Michael Van Canneyt wrote:
> On Mon, 18 May 2009, Jonas Maebe wrote:
> > On 18 May 2009, at 16:39, Leonardo M. Ramé wrote:
> > >Apparently my program gets stuck after a couple (several, in fact) of
> > > calls to the function that includes this code.
> > >
> > >By reading the FPC.RTL documentation, I found it says that FindClose
> > > must be used outside the if, as follows:
> > >
> > >if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then
> > >begin
> > > repeat
> > >   ...
> > >   ...
> > >until FindNext(sr) <> 0;
> > >end;
> > >FindClose(sr);
> > >
> > >Can be this the cause of the problem in my application?.
> >
> > Yes.
>
> Huh ? Since when is this requirement ?
>
> If it is correct, 100% of my FindFirst/FindClose code must be rewritten !
>
> Michael.




More information about the fpc-pascal mailing list