Bad allocation

188 views
Skip to first unread message

Luděk Rous

unread,
Aug 28, 2014, 8:08:44 AM8/28/14
to pdfne...@googlegroups.com
Hi,
when i view a big PDF file (http://download.fraus.cz/pdf/Prirodopis_7.pdf), memory increases so far and after some time (viewed pages) i get an Error "bad allocation". It is in version 6.2.1.23937 and i use e_BuiltIn PDFRasterizer type. 
When i use old version 5.8.0, it uses max about 350 MB memory.
Do i something wrong? 

Thanks a lot
Luděk Rous

Tomas Hofmann

unread,
Aug 28, 2014, 1:35:24 PM8/28/14
to pdfne...@googlegroups.com
Hi Luděk,

We identified a possible problem with memory that seems to only appear on some devices. This was fixed shortly after 6.2.1, and should be part of 6.2.3, which is out current release. Please download our latest version from our website and give it a try:

The problem showed itself on some computers when you scrolled too fast. It seemed that GC couldn't keep up with the recycling of memory, so we implemented our own recycling of some UI elements. This fixed the problem described.

If this does not fix your problem, please let us know and we will take a look. Also, please let us know how you are using the viewer (page presentation mode, sequence of actions that trigger the problem, and so on). Also, we would need either a small sample that can be used to reproduce the problem, or a way to reproduce it on one of our own samples.

Best Regards,
Tomas Hofmann

Luděk Rous

unread,
Sep 1, 2014, 6:19:04 AM9/1/14
to pdfne...@googlegroups.com
Hi Tomas, 
switch to version 6.2.3 unfortunately does not fix my problem. But the problem is really curious. I test your sample PDFViewWPFSimpleTestCS2012 on two devices. 

The first one is my development computer:
Intel Core i5 - 2500K
16GB RAM
ASUS RAIDR Express PCIe 240GB
AMD Radeon R7 200 Series

The second one is:
ASUS Transformer Book T100TA-DK002H, 32GB
Intel Atom Z3740 1.33 Ghz  
2GB RAM
Intel HD Graphics 

The problem appears when i browse the PDF fast and presentation mode is PagePresentationMode.e_facing. The curiosity is, that the problem appears only on my development computer. The memory increases to 1200MB and then the PDFViewWPFSimpleTestCS2012 crashes. On the second device it looks like the memory collection works. The memory increases max to 850MB and PDFViewWPFSimpleTestCS2012 still runs.

Dne čtvrtek, 28. srpna 2014 14:08:44 UTC+2 Luděk Rous napsal(a):

Luděk Rous

unread,
Sep 3, 2014, 2:17:29 AM9/3/14
to pdfne...@googlegroups.com
Hi Tomas,
i did not describe versions of operating systems on these devices and the version of library. I need to use 32bit library for both version of OS for several reasons.
The first device is Miscrosoft Windows 8.1 64bit and the second one is Miscrosoft Windows 8.1 32bit. When i test PDFViewWPFSimpleTestCS2012 64bit on 64bit OS, everything is OK. Memory increases to max to 2GB, but the PDFViewWPFSimpleTestCS2012 do not crash and still runs. So it seems that only 32bit library crashes on 64bit systems.

Dne čtvrtek, 28. srpna 2014 14:08:44 UTC+2 Luděk Rous napsal(a):
Hi,
Message has been deleted
Message has been deleted

Tomas Hofmann

unread,
Sep 4, 2014, 6:49:06 PM9/4/14
to pdfne...@googlegroups.com
Hi Luděk and Lan,

This is a problem with GC. For some reason (that we don't know ourselves) on some devices (usually more powerful ones) resources aren't recycled quickly enough, and it runs out of memory.
We have rectified this by recycling things ourselves, but it's not part of the official release.

We will move these changes into our stable branch and provide you both with a build early next week (Hopefully on Monday).

Best Regards,
Tomas Hofmann

On Tuesday, September 2, 2014 11:56:48 PM UTC-7, Lan wrote:
Is your first computer x86?
I have seen the same problem only on x86 machines.

Lan
On Monday, September 1, 2014 6:19:04 PM UTC+8, Luděk Rous wrote:
> Hi Tomas, 
> switch to version 6.2.3 unfortunately does not fix my problem. But the problem is really curious. I test your sample PDFViewWPFSimpleTestCS2012 on two devices. 
>
>
> The first one is my development computer:
> Intel Core i5 - 2500K
> 16GB RAMASUS RAIDR Express PCIe 240GB

Tomas Hofmann

unread,
Sep 8, 2014, 5:40:03 PM9/8/14
to pdfne...@googlegroups.com
Hi Luděk and Lan,

We have two new builds complete for you. They can be downloaded here. Please try them out and let us know if this solves your problems.


Best Regards,
Tomas Hofmann

Luděk Rous

unread,
Apr 15, 2016, 12:36:02 PM4/15/16
to PDFTron PDFNet SDK
Hi Tomas,
I did not write for a long time. I found another problem with bad allocation.
Our application has to be build only as x86 for 32 bit OS, because of other dependent libraries (Awesomium). Until this time, everything was fine. But now i implement a tab control like in PDFViewWPFSimpleTestCS2012. When i open usual PDF´s, everything works fine. But we have a some PDF´s (http://files.flexilearn.cz/PDF/prvouka1.pdf) that are big and contains a lot of graphic objects. When i try to open more than 3 in tab control on 64bit OS, library throws me a BadAllocation exception. I tried to build PDFViewWPFSimpleTestCS2012 as x86, open this PDF in 3 tabs and it throws me this Exception as well. When i build my app without Awesomium as x64 everything is fine. In PDFViewWPFSimpleTestCS2012 as well.

Ryan

unread,
Apr 15, 2016, 1:35:11 PM4/15/16
to PDFTron PDFNet SDK
Is only one tab visible at a time? If so, please see the following forum post on how to deactivate hidden tabs.

Luděk Rous

unread,
Apr 19, 2016, 12:58:21 PM4/19/16
to PDFTron PDFNet SDK
Hi Ryan,
thank you for your reply but for me this methods unfortunately does not work. 

When i built my app for 32bit (x86) I opened max 2 tabs with our large PDF (http://files.flexilearn.cz/PDF/prvouka1.pdf) and the third attempt ended with exception (bad allocation or SystemOutOfMemoryException).
But when i built my app for 64bit (x64) I opened a 15 tabs, browsed the books and no exception occured (cca 5 000 MB in RAM). In PDFViewWPFTest built for 32bit i opened max 11 and then i got following exception (cca 750 MB in RAM). Sometimes I got bad allocation when I browsed the book (around 10 tabs opened).

Exception: 
Message: To handle this command is not enough space (translated from Czech language)
Conditional expression: ip::interprocess_exception
Filename: MapppedFile.cpp
Function: trn::Filters::MappingManager::CreateMapping
Linenumber: 260

I know that is the reason why are 2 version (x68 a x64) available, but i really need to make my 32bit app to work on 64bit OSs.

Thanks a lot 

Ludek

Ryan

unread,
Apr 19, 2016, 1:16:00 PM4/19/16
to PDFTron PDFNet SDK
There will always be a limit to what you can do in a 32bit process, as on Windows there is a max 3GB limit.

First, is your 32bit application large address aware? After compiling, you should add a post build step to do the following.

editbin /LARGEADDRESSAWARE 'your exe'

See this blog post for more about this.

Otherwise, beyond calling Deactivate on tabs, you might also want to just close the document (but store the page number, and maybe zoom and scroll positions). Then when the user goes back to that tab, re-open the document and jump to the page. Of course, you will need to add some logic for handling a modified document (where a user might of added an annotation).
Reply all
Reply to author
Forward
0 new messages