I have an application that provides print functionality and the ability to do a preview of that print. Print preview is handled using a PrintPreviewDialog
. The application is a C# WinForms .Net 4.0 application.
In essence, the function is printing (previewing) a multi-page report, and in this particular instance it is previewing a large number of image files (about 950 at 2 images per page).
In this case, the application is throwing an error at page 462 (so not too far off the total), and at that time the following task manager values are available:
- Memory (PWS): ~1.6GB
- Handles: ~480
- User Objects: ~300
- GDI Objects: ~1400
I am sure that the memory (although high) is not the issue, as I would expect an out of memory exception. The GDI objects is getting on a bit, but I don't think this is too high (I believe the limit by default is 10000?)
The actual exception message being shown is the ever helpful:
A generic error occurred in GDI+
A few other things to be wary of:
- This is an application running at a customer's site, so there is no ability to run a debugger
- The images are first loaded into memory as a collection of
Image
objects (which explains the high GDI Object count) and this cannot be changed at this stage - I have not yet confirmed if this is also an issue when doing a real print, obviously nobody wants to waste all that paper, but I am awaiting the results of a Print to PDF test
Finally, my question is: Are there any limits I should be aware of that might cause this behavior? Such as a Windows limit that might be set in the Registry. Something related to print memory? or a different GDI limit for print?
Are there any further tests I could run to help diagnose the cause?