You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jay <di...@gmail.com> on 2007/09/03 15:53:36 UTC

Re: Out of Memory Exception while loading Images.

Hi All,

Just to update on this.

We have increased RAM on JVM. It seems that large objects (in this case FOP
byte stream) requires continuous memory allocation, I believe. This requires
GC more work, and because of less memory available, GC was not able to keep
itself upto the speed to user requests. For now, We went with the Last
option we had(i.e. increasing the RAM)

I am just thinking, is it possible to flush the output out, if FOP byte
stream exceeds the limit? This would help us to deal with large objects like
images etc. ?

Any thoughts ?


On 8/30/07, Jay <di...@gmail.com> wrote:
>
> Hi,
>
> I tested using three attached images. Using these images also caused an
> out of memory exception.
> Note that I used these three images, but loaded total 8 images using a
> loop.
>
> Please find images attached.
> The only notable difference about these images is that these images are
> resizes and renamed using ImageMagik.
>
> *Here is xsl-fo:*
>
>
> * * <xsl:variable name=" *imgLocation*" select="*
> eOptions/@pdfImageLocation *" />
>
> *-* <xsl:for-each select ="*//eOptions/sections/photo-section/photo*">
>
> *-* <fo:table-row >
>
> * * <xsl:variable name=" *imgWidth*" select="*@width* " />
>
> * * <xsl:variable name=" *imgHeight*" select="*@height* " />
>
> *-* <fo:table-cell padding-left ="*1.0cm*">
>
> *-* <fo:block >
>
> *-* <fo:external-graphic content-width ="*{$imgWidth}cm*" content-height
> ="*{$imgHeight}cm*">
>
> *-* <xsl:attribute name ="*src*">
>
> * * <xsl:value-of select ="*@location1*" />
>
> * * </xsl:attribute>
>
> * * </fo:external-graphic>
>
> * * </fo:block>
>
> * * </fo:table-cell>
>
> * * <fo:table-cell>* * </fo:table-cell>
>
> *-* <fo:table-cell padding-left ="*1.0cm*">
>
> *-* <fo:block >
>
> *-* <fo:external-graphic content-width ="*{$imgWidth}cm*" content-height
> ="*{$imgHeight}cm*">
>
> *-* <xsl:attribute name ="*src*">
>
> * * <xsl:value-of select ="*@location2*" />
>
> * * </xsl:attribute>
>
> * * </fo:external-graphic>
>
> * * </fo:block>
>
> * * </fo:table-cell>
>
> * * </fo:table-row>
>
> *-* <fo:table-row >
>
> *-* <fo:table-cell number-columns-spanned ="*3*">
>
> *-* <fo:block >
>
> *-* <xsl:call-template name ="*imageShim*">
>
> *-* <xsl:with-param name ="*id*">
>
> * * <xsl:value-of select ="*$imgLocation*" />
>
> * * </xsl:with-param>
>
> *-* <xsl:with-param name ="*logo*">
>
> * * <xsl:value-of select ="*'shim.gif'*" />
>
> * * </xsl:with-param>
>
> * * </xsl:call-template>
>
> * * </fo:block>
>
> * * </fo:table-cell>
>
> * * </fo:table-row>
>
> * * </xsl:for-each>
>
> Please let me know in case you need more information.
>
> Thanks,
> Digvijay
>
>  On 8/29/07, Manuel Mall <ma...@apache.org> wrote:
> >
> > On Wednesday 29 August 2007 15:49, Jay wrote:
> > > Hi All,
> > >
> > > Can anyone please help me out here ?
> > > I am trying to get the FOs and images as suggested by Adrian, but
> > > looks like its any type of image which is causing this error.GIF,
> > > .JPG etc.
> > >
> > > Is there something very obvious I might be missing here ?
> > > Appreciate your help.
> > >
> > Jay,
> >
> > you said initially that the problem only occurred once in production.
> > Can you reproduce it in your development environment? Does it happen
> > when you run FOP from the command line? Have you checked, e.g. by
> > monitoring the JVM, that you don't have a memory leak? Is it a Java
> > server based application (e.g. FOP embedded in Tomcat or a JEE server)
> > or is FOP invoked from the command line each time?
> >
> > Manuel
> >
> > > Thanks,
> > > Digvijay.
> > >
> > >
> > > On 8/28/07, Jay < digpat@gmail.com <ma...@gmail.com> > wrote:
> > >
> > >
> > > Hi,
> > >
> > > The images are JPG.
> > >
> > > And here is the stack trace:
> > >
> > > java.lang.OutOfMemoryError
> > > java.lang.StringBuffer.expandCapacity(StringBuffer.java(Inlined
> > > Compiled Code))
> > > java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
> > > sun.net.www.protocol.file.FileURLConnection.getInputStream
> > > (FileURLConnection.java(Compiled Code))
> > > org.apache.fop.apps.FOURIResolver.resolve (FOURIResolver.java:153)
> > > org.apache.fop.apps.FopFactory.resolveURI(FopFactory.java:638)
> > > org.apache.fop.apps.FOUserAgent.resolveURI ( FOUserAgent.java:421)
> > > org.apache.fop.apps.FOUserAgent.resolveURI (FOUserAgent.java:395)
> > > org.apache.fop.image.ImageFactory.loadImage(ImageFactory.java:190)
> > > org.apache.fop.image.ImageLoader.loadImage(ImageLoader.java :56)
> > > org.apache.fop.image.ContextImageCache.getImage (ImageFactory.java:432
> > >) org.apache.fop.image.ImageFactory.getImage(ImageFactory.java:157)
> > > org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:68)
> > > org.apache.fop.fo.FObj.processNode(FObj.java (Compiled Code))
> > > org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuil
> > >der .java(Compiled Code))
> > > org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java
> > > (Compiled Code))
> > > org.apache.xml.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandl
> > >er. java(Compiled Code))
> > > org.apache.xml.serializer.ToSAXHandler.flushPending(ToSAXHandler.java
> > >(Co mpiled Code))
> > > org.apache.xml.serializer.ToXMLSAXHandler.endElement
> > > (ToXMLSAXHandler.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates (Tr
> > >ans formerImpl.java (Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates (Tr
> > >ans formerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates (Tr
> > >ans formerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute
> > > (ElemLiteralResult.java(Compiled Code))
> > > org.apache.xalan.templates.ElemForEach.transformSelectedNodes (ElemFor
> > >Eac h.java(Compiled Code))
> > > org.apache.xalan.templates.ElemForEach.execute(ElemForEach.java(Compi
> > >led Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
> > > ( TransformerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java (Compiled Code))
> > > org.apache.xalan.templates.ElemIf.execute(ElemIf.java(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java (Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute
> > > (ElemLiteralResult.java(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java (Compiled Code))
> > > org.apache.xalan.templates.ElemIf.execute(ElemIf.java(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
> > > (TransformerImpl.java(Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java (Compiled Code))
> > > org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResul
> > >t.j ava(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Tr
> > >ans formerImpl.java(Compiled Code))
> > > org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Tran
> > >sfo rmerImpl.java:2245)
> > > org.apache.xalan.transformer.TransformerImpl.transformNode(Transforme
> > >rIm pl.java:1334)
> > > org.apache.xalan.transformer.TransformerImpl.transform
> > > (TransformerImpl.java:738)
> > > org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
> > >l.j ava:1251)
> > > org.apache.xalan.transformer.TransformerImpl.transform (TransformerImp
> > >l.j ava:1229)
> > >
> > > Let me see if I can host images somewhere and share FO using them,
> > > but it could take sometime.
> > > Thank you Adrian for your suggestions.
> > >
> > > Thanks,
> > > Digvijay
> > >
> > >
> > > On 8/28/07, Adrian Cumiskey < adrian.cumiskey@gmail.com
> > > <mailto:adrian.cumiskey@gmail.com > > wrote:
> > >
> > > Hi Jay,
> > >
> > > What type of images are they?  Also please provide the full exception
> > > stack trace.  If you could host the images somewhere along with the
> > > FO which references them so they could be referenced in a test that
> > > would be helpful also.
> > >
> > > Adrian.
> > >
> > > Jay wrote:
> > > > Hi All,
> > > >
> > > > This is Digvijay. Joined recently to this group.
> > > >
> > > > I am using FOP 0.93 in one of my projects which went to production
> > > > yesterday.
> > > > As soon as users started downloading PDFs, application started
> > >
> > > throwing
> > >
> > > > Out of Memory Exception.
> > > >
> > > > One obvious reason,we concluded was that, we need to increase some
> > >
> > > memory.
> > >
> > > > But even when our Support Team added more vitual memory to the
> > > > server box, exceptions kept coming.
> > > >
> > > > These PDFs have one page section which has 8 images (around 1MB
> > > > each) and I observerd that always exception occured when FOP tried
> > > > to read these images.
> > > >
> > > > Is anyone aware of similar issue with this version of FOP.  I
> > > > browsed through the archieves but did not find anything of
> > > > interest. Can someone help me out ? Or give me some pointers ?
> > > >
> > > > Appreciate your help.
> > > >
> > > > Thanks,
> > > > Digvijay.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > <ma...@xmlgraphics.apache.org>
> > > fop-users-unsubscribe@xmlgraphics.apache.org
> > > For additional commands, e-mail:
> > > fop-users-help@xmlgraphics.apache.org
> > > <mailto: fop-users-help@xmlgraphics.apache.org>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> >
> >
>
>

Re: Out of Memory Exception while loading Images.

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jay wrote:
> I am just thinking, is it possible to flush the output out, if FOP byte
> stream exceeds the limit? This would help us to deal with large objects like
> images etc. ?

Ordinary byte streams are flushable. The problem is more likely caused
by using a ByteArrayOutputStream, which is used to get the actual
length of the PDF content in order to put it into the appropriate
HTTP-header, which in turn is necessary for IEx up to at least release
5.5 to display PDFs at all (many thanks to Redmond for this baggage).

It would be interesting to explore whether more recent IEx releases
still have this problem, and/or whether it could be mitigated by
sending the PDF as file attachment.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org