1

I am using itext library for pdf generation of multiple pages .and once pdf is generated I want to view that pdf for that I am using .properties file as pdfView.(class)=pakg.pdfBuilder . where pdfBuilder() is method which contains code of pdf where I have created Document variable and added paragraphs into it plus I have added images then applying watermark to those images. but while generating multiple pdf's ,few pdfs are generating but then I am getting error about heap memory as:

java.lang.OutOfMemoryError: Java heap space

how do I save heap memory?

Krunal
  • 77,632
  • 48
  • 245
  • 261
  • 1
    The first step would be to provide your application with a higher heap space limit. Check out [this question](https://stackoverflow.com/questions/14763079/what-are-the-xms-and-xmx-parameters-when-starting-jvms)'s answers. – f1sh Jul 10 '17 at 09:28
  • ¿Are you using the default JVM memory options? Please specifiy the JDK/JRE used and any options used to launch the program – Dubas Jul 10 '17 at 09:28

1 Answers1

0

If you are using the default JVM settings probably the amount of memory is not sufficient.

For example try to increase the memory to -Xmx512M (512 MB) or more.

To see about default Java 1.8 memory sizes check: Default Xmxsize in Java 8

Take in care that increasing the amount of memory exceeding the limits of the memory that could be allocated by the JVM could cause that your application won't start (This depends on your JVM installation architecture (x86 vs x64), the amount of memory of your system and the amount of memory usable..

Dubas
  • 2,855
  • 1
  • 25
  • 37