If you're using a 32 bit JVM you can only have around 3GB in the latest
JVMs. You need
-bdb


On Tue, Mar 3, 2009 at 11:47 AM, Massimiliano Ziccardi <
[email protected]> wrote:

> Thank you for your answer.
>
> I think the problem is elsewhere: here is the test I did.
>
> I have 1GB file.
> I copied the 1GB file 9 times.
>
> Than I started signing them: the first file is signed OK, while the second
> gives me the OutOfMemory error.
>
If you're using a 32 bit JVM you can only have around 3GB in the latest
JVMs. Plus, in Strings, the JVM has more than one copy of the chunks of data
- this can lead to (sometimes) as much as a factor of 10 memory requirement
if you pass the strings around a lot of create copies, etc.

Recall the JVM uses async garbage collection, so you can't really control
when the memory is "freed" for you next file.

You might have to use 64 bit JVM to get above the 4gb (theoretical) limit of
heap, or, restart the jvm after each one.

9 1GB files in memory with all the extras iText probably has is way over the
limits of a 32 bit JVM.

>
> Could it be a memory leak?
>
> Thanks in advance,
> Massimiliano
>
> On Tue, Mar 3, 2009 at 5:26 PM, Paulo Soares <[email protected]> wrote:
>
>> If you have a lot of object it will still require a lot of memory to store
>> the xrefs and other housekeeping objects.
>>
>> Paulo
>>
>> > -----Original Message-----
>> > From: Massimiliano Ziccardi [mailto:[email protected]]
>> > Sent: Tuesday, March 03, 2009 4:10 PM
>> > To: [email protected]
>> > Subject: [iText-questions] OutOfMemory error
>> >
>> > Hi all.
>> >
>> > I need to sign 9 files each of them 1GB long...
>> >
>> > I instantiate the reader with
>> > PdfReader reader = new PdfReader(new
>> > RandomAccessFileOrArray(fIn.getAbsolutePath(), false, true),null);
>> >
>> > and then I add the signature with:
>> >
>> > PdfStamper stp = PdfStamper.createSignature(reader, new
>> > BufferedOutputStream(new FileOutputStream(fOut)), '\0', fTmp, true);
>> >
>> > But I get the following OutOfMemory error...
>> >
>> > Acrobat reader is able to deal the file very efficiently
>> > (small memory footprint and very fast).
>> >
>> > Do you have any idea?
>> >
>> >  java.lang.OutOfMemoryError: Java heap space
>> >     at java.lang.String.toCharArray(String.java:2726)
>> >     at com.lowagie.text.pdf.PdfName.<init>(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readDictionary(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readPRObject(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readDictionary(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readPRObject(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readDictionary(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readPRObject(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.readSingleObject(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.getPdfObject(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.getPdfObject(Unknown Source)
>> >     at
>> > com.lowagie.text.pdf.PdfReader$PageRefs.getSinglePage(Unknown Source)
>> >     at
>> > com.lowagie.text.pdf.PdfReader$PageRefs.getPageOrigRef(Unknown Source)
>> >     at
>> > com.lowagie.text.pdf.PdfReader$PageRefs.getPageN(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.getPageN(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfReader.getPageNRelease(Unknown Source)
>> >     at com.lowagie.text.pdf.AcroFields.fill(Unknown Source)
>> >     at com.lowagie.text.pdf.AcroFields.<init>(Unknown Source)
>> >     at
>> > com.lowagie.text.pdf.PdfStamperImp.getAcroFields(Unknown Source)
>> >     at
>> > com.lowagie.text.pdf.PdfSignatureAppearance.getNewSigName(Unkn
>> > own Source)
>> >     at
>> > com.lowagie.text.pdf.PdfSignatureAppearance.<init>(Unknown Source)
>> >     at com.lowagie.text.pdf.PdfStamper.createSignature(Unknown Source)
>> >
>> >
>> > Thank you in advance,
>> > Massimiliano
>> >
>> >
>>
>> Aviso Legal:
>> Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
>> informação confidencial ou legalmente protegida. A incorrecta transmissão
>> desta mensagem não significa a perca de confidencialidade. Se esta mensagem
>> for recebida por engano, por favor envie-a de volta para o remetente e
>> apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o
>> destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.
>>
>> Disclaimer:
>> This message is destined exclusively to the intended receiver. It may
>> contain confidential or legally protected information. The incorrect
>> transmission of this message does not mean the loss of its confidentiality.
>> If this message is received by mistake, please send it back to the sender
>> and delete it from your system immediately. It is forbidden to any person
>> who is not the intended receiver to use, distribute or copy any part of this
>> message.
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
>> CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source
>> participation
>> -Receive a $600 discount off the registration fee with the source code:
>> SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>>
>
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source code:
> SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
>
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to