ICEpdf
  1. ICEpdf
  2. PDF-585

OutOfMemoryError due to ImageUtility.makeImageWithRasterFromBytes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.1
    • Fix Version/s: 5.0.3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Pro, JAI
    • Salesforce Case Reference:
    • Workaround Description:
      The image is quite large 4959x3506. Recommend increasing the heap sized to -Xmx256m .

      Description

      The PDF renders correctly, when compared to Adobe, but the following exception is thrown:

      java.lang.OutOfMemoryError: Java heap space
      at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
      at java.awt.image.Raster.createPackedRaster(Raster.java:458)
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorMo
      del.java:1015)
      at java.awt.image.BufferedImage.<init>(BufferedImage.java:324)
      at org.icepdf.core.pobjects.ImageUtility.makeImageWithRasterFromBytes(ImageUtil
      ity.java:1461)
      at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:403)
      at org.icepdf.core.pobjects.ImageStream.getImage(ImageStream.java:295)
      at org.icepdf.core.pobjects.graphics.ImageStreamReference.run(ImageStreamRefere
      nce.java:66)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
      va:895)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
      18)
      at java.lang.Thread.run(Thread.java:680)

        Activity

        Hide
        Patrick Corless added a comment -

        The image in question is quite large and requires that the JVM be assinged more memory. I would recommend setting the system property -Xmx256m.

        Show
        Patrick Corless added a comment - The image in question is quite large and requires that the JVM be assinged more memory. I would recommend setting the system property -Xmx256m.
        Hide
        Tyler Johnson added a comment -

        Both the user and I still see the exception with heap size -Xmx256m, -Xmx512m and -Xmx1024m

        Show
        Tyler Johnson added a comment - Both the user and I still see the exception with heap size -Xmx256m, -Xmx512m and -Xmx1024m
        Hide
        Patrick Corless added a comment -

        Tyler can you get the JVM and OS being used?

        Show
        Patrick Corless added a comment - Tyler can you get the JVM and OS being used?
        Hide
        Tyler Johnson added a comment -

        Tested on Win 7 and Win 8 with JVM 7 update 21.

        Show
        Tyler Johnson added a comment - Tested on Win 7 and Win 8 with JVM 7 update 21.
        Hide
        Patrick Corless added a comment -

        Going to give a closer look.

        Show
        Patrick Corless added a comment - Going to give a closer look.
        Hide
        Patrick Corless added a comment -

        There isn't much we can do to improve the memory usage in this case. The image is quite large /Width 4959 /Height 3506 and is also masked by an image that is the same size. Effectively we create three image to render the final image. I'll have to look and see if there is a way to optimize the masking process to try and reduce the total amount of memory used.

        Show
        Patrick Corless added a comment - There isn't much we can do to improve the memory usage in this case. The image is quite large /Width 4959 /Height 3506 and is also masked by an image that is the same size. Effectively we create three image to render the final image. I'll have to look and see if there is a way to optimize the masking process to try and reduce the total amount of memory used.
        Hide
        Patrick Corless added a comment -

        Marking as resolved. Reworked imaging code to avoid creating a new RGBA image as we are already working with an image that has an alpha value.

        Show
        Patrick Corless added a comment - Marking as resolved. Reworked imaging code to avoid creating a new RGBA image as we are already working with an image that has an alpha value.

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Tyler Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: