Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

too many open filehandles #57

Open
gfpos opened this issue May 17, 2019 · 1 comment
Open

too many open filehandles #57

gfpos opened this issue May 17, 2019 · 1 comment
Assignees

Comments

@gfpos
Copy link

gfpos commented May 17, 2019

this is from using templates:

            pdfOut.AddPage();
            tpl = pdfOut.ImportPage( i );
            pdfOut.UseTemplate( tpl );

works fine as long as i am using less then 512 files.
above that number my program crashes.
Reason is:
windows-7 has a maximum of 512 open files by default.
you can increase that number easily by - _setmaxstdio (2048) - , but it would be better just
to close the handle after assigning the template to the new PDF, because this is just another limitation.
there should be no such limitation of files in general

btw: great job

@utelle
Copy link
Owner

utelle commented May 17, 2019

Unfortunately this issue is not as easy to fix. Although the content of a template is inserted immediately on calling UseTemplate, the template may reference resources (like graphics or fonts) which have to be extracted from the PDF source file, too, later on. In the current version of wxPdfDocument such resources are extracted only when finishing the resulting PDF document. The reason is that only then it is known which resources from a certain PDF source file are actually required.

To overcome the issue it would be necessary to temporarily close a source PDF file when it is no longer used and to reopen it while finalizing the resulting PDF document. Since several pages could be extracted from a source PDF file and templates could be used more than once, the user would have to tell wxPdfDocument when he doesn't want to access a certain source PDF file any longer.

Reinitializing the PDF parser associated to a certain PDF source file is not trivial, and processing more than 512 (or even 2048) PDF source files for a single resulting PDF document represents an uncommon special case. Therefore I fear I will not be able to provide a solution in the near future.

I have plans to overhaul wxPdfDocument in the future and will then certainly address this issue as well.

In the meantime it would probably make sense to adjust wxPdfDocument if necessary, so that it detects situation when the limit of open files is reached. Maybe you could provide additional information about your program's crash, allowing to identify the code in wxPdfDocument leading to the crash. Thanks.

@utelle utelle self-assigned this May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants