[Gambas-user] Too many open files error message

Benoît Minisini gambas at ...1...
Tue May 4 19:50:25 CEST 2010


> This routine is called by my program, consecutively a large number of times
> during an automated process:
> 
> Public Sub Display_HTML(sHTML As String, wb As WebView, Optional prefix As
> String = "html")
> 
>   Dim wFile As File
>   Dim sFilename As String
> 
>   sFilename = Temp$(prefix) & ".html"
>   wfile = Open sFilename For Write Create
>   Print #wfile, sHTML
>   Close #wfile
>   wb.url = sFilename
> End
> 
> the temp file is opened-closed.
> 
> Yet at a certain point gambas comes up with an error 24: too many opened
> files. Does this mean the temp-file quota has somehow been exceeded?
> 
> It makes no difference if I put in a fixed name like this:
> 
> sfilename = "/home/richard/temp.html"
> 
> Same result > it eventually bugs out. and complains
> Regards
> 
> Richard
> 

Apparently you close the file you wrote, so maybe the problem comes from 
elsewhere.

You can check which files you are really open by using "strace". Enter the 
directory of your project, and type "strace gbx2" (or "strace gbx3" if you use 
Gambas 3). All system calls will be printed, and you can analyze the output to 
see when the open() and close() system calls are used.

You can check too your project, by printing a debugging message when you open 
a file and when you close it, to see if you didn't forget to do that. Note 
that a file is automatically closed when the File object is released.

I can't say more at the moment without more information. I'm not sure it is a 
Gambas bug.

Regards,

-- 
Benoît Minisini




More information about the User mailing list