moonpdf icon indicating copy to clipboard operation
moonpdf copied to clipboard

Out of Memory exception when scrolling large PDFs

Open lukamicoder opened this issue 10 years ago • 2 comments

If you open a large and long (>250 pages) PDF, maximize the window, set zoom to fit width, grab the scroll bar and start to pull it down, not too slow nor too fast, you will get this error: "An unhandled exception of type 'System.OutOfMemoryException' occurred in PresentationCore.dll" at line 36 of BitmapExtensionMethods.cs.

lukamicoder avatar May 20 '15 22:05 lukamicoder

I have same problem.

When I open a large and long (>250 pages) PDF, maximize the window, set zoom to fit width or bigger, grab the scroll bar and start to pull it down, not too slow nor too fast, I will get this error: "An unhandled exception of type 'System.OutOfMemoryException' occurred in PresentationCore.dll" at line 36 of BitmapExtensionMethods.cs (constructor of WriteableBitmap class). When the application is running, the memory usage extremely increase.

I put these lines after "var img = new PdfImage { ImageSource = bms, Margin = margin };" in PdfImageProvider.cs in your source, but not worked:

bms = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();

I use the library in .Net 4.5, Windows 8 (x86!) with 4GB memory.

Can You help me, please?

Thanks

kerektamas avatar Jul 04 '16 09:07 kerektamas

Hi, guys. You can set MaxZoomFactor property of MoonPdfPanel based on your situation. For example, set 2.8 to MaxZoomFactor is OK when I using one file contains 906 pages while setting 3.0 to MaxZoomFactor will out of memory.

NaughtyCatRun avatar May 11 '17 04:05 NaughtyCatRun