• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

OutOfMemoryError during the pdf report generation

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hei there,

In my web application, the user searches for a policy though the web interface, which i will find in the file server, the policy is in the form of pdf file, and respond them. there is also an option to search multiple policies, find them and print them in single attempt. in this case, i find those policy pdf files from a file server and combine them into one single pdf and write the bytes to the servlet output stream. in this case OutOfMemoryError is raised if more files are attempted to print. the combined single pdf file may run to hundreds of pages. i use itext to combine the pdfs.

FYI
I combine all the pdf
I am using clustered WAS server in AIX environment.

how do i solve this memory problem, as the client is specific in improving the speed and number of report printed?
Does increasing the JVM size may improve the situation, if so what if more files are combined and printed?
does data compression improve this situation? or is it an overhead?


thanks
V
 
JavaMonitor Support
Posts: 251
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your heap size set to? (-Xmx flag on the command line)
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if the number of request is going to be high, Instead of combining the files in run time, combine them offline and place in the same folder, based on the user request you can serve the file what ever he want. (this will iff the number of files going to be limited)
 
az ziz
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your replies.

I cannot combine the pdfs offline as the requested reports may be random, each time. but I can only combine the list of reports requested runtime, no matter how old it is.

thanks
V
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to use ReferenceQueue when one file is written on the stream..i didn't got the corrrect context in your problem. But definitely if you use this approach before jvm throws any OutOfMemory it releases all the object that you have enqued in the ReferenceQueue and thus you can avoid this outOfmemory
 
az ziz
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok let me try to explain it again.

I have a scheduler which runs periodically and generate reports in the form of pdf, fetching data from the database and save it to the file server. This part is separate.

Now in the web interface of the project the end user searches for a/few "policy(ies)", ie the report, an application in the web module will find the corresponding reports in the file server. as more reports are found the results of the search fetches few files. As the user requirement is to view these reports in a single pdf file, i merge all the found pdf report files using itext library and write them to the ServletOutputStream. the avg size of a pdf file will be around 300kb. say for example i have 30 - 40 reports searched, i combine them into a single pdf file using the itext and write the bytes into the stream. in this scenario while i merge the pdf, say in between 25th or 30th pdf, the server throwing the OutOfMemory exception.
i felt its due to the size of the combined file?

hope i had explained things clearly

thanks
V
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vijay Veeraraghavan.V wrote:
i felt its due to the size of the combined file?



That is quite possible. Have you performed any tests to confirm your suspicion?
You still haven't answered Kees Jan Koster's question, which is another important piece to the puzzle. If the problem is the amount of memory available at one time (as opposed to a memory leak, where the memory is consumed and never returned), increasing the heap may be your solution.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are there other computers on your network you could hand off the pdf combining job to?

Due to the (presumed) random nature of request coming to your server, there is always a possibility of "simultaneous" requests overloading the server no matter how much memory it has.

Bill
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, have you considered using something other than iText. iText is very powerful. An API/library that just merges PDFs may use a lot less memory since that is all it has to do.
 
az ziz
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for all your replies.
the jvm inside which the WAS runs has 1024 MB memory.
as Mr. Jeanne suggests, i am trying with other libraries such as pdfbox and PJX.


thanks
V
 
Where does a nanny get ground to air missles? Protect this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic