Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088231

[WebView] Reloading large images causes java.lang.OutOfMemoryError: Java heap space

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • 9
    • 8u25, 9
    • javafx
    • None
    • web

      Ideally, the background processing of getting images should stop when a new request comes along because of a new call to WebView.getEngine().load(String)

      Because it doesn't stop, I have a reproducible test case for making a vm run out of heap space:

      1) Compile and run the SimpleSwingBrowser location here:
      https://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm

      2) Have go the url of a large image (this one is about 5.9 MB):
      http://chamorrobible.org/images/photos/gpw-200905-UnitedStatesAirForce-090414-F-6911G-003-Pacific-Ocean-B-2-Spirit-stealth-bomber-F-22A-Raptor-stealth-fighters-Guam-April-2009-huge.jpg

      3) while the image is loading, press the "go" button to start loading the page a few times until you run out of heap (6 times is enough javafx to fill up 256MB max heap:

      Exception in thread "JavaFX Application Thread" java.lang.OutOfMemoryError: Java heap space

      4) Utilizing a profiler like YourKit, the culprit at the time of the OutOfMemoryError seems to be that there are 6 "Strongly Reachable" instances of com.sun.javafx.webkit.prism.WCImageDecoderImpl that are collectively holding onto a retained size of 175MB of heap.

      The retained size is originating from the the java.nio.HeapByteBuffer:

      com.sun.javafx.webkit.prism.WCImageDecoderImpl is holding onto
        com.sun.javafx.iio.ImageFrame[] which continues to hold onto
        147MB of java.nio.HeapByteBuffer

            mbilla Murali Billa
            jfrankovijfx JJ Frankovich (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: