ICEpdf
  1. ICEpdf
  2. PDF-598

FreeText font resources are getting garbage collected.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.2
    • Fix Version/s: 5.0.3
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      any
    • Salesforce Case Reference:

      Description

      A client has reported the following stack trace which is generated after creating and moving freeTextAnnotations. I've been able to isolate a reproducible test case. Limit the heap to 64mb, create a freeTextAnnotation on the first page, load 50 or so pages, come back to the first page and the move the free text annotation or try and edit it.

      java.lang.NullPointerException
      at org.icepdf.core.pobjects.Resources.getFont(Resources.java:141)
      at
      org.icepdf.core.pobjects.annotations.FreeTextAnnotation.resetAppearanceStream(FreeTextAnnotation.java:519)
      at
      org.icepdf.core.pobjects.annotations.Annotation.resetAppearanceStream(Annotation.java:1572)
      at
      org.icepdf.ri.common.views.annotations.FreeTextAnnotationComponent.resetAppearanceShapes(FreeTextAnnotationComponent.java:259)
      at
      org.icepdf.ri.common.views.annotations.FreeTextAnnotationComponent.mouseDragged(FreeTextAnnotationComponent.java:207)
      at java.awt.Component.processMouseMotionEvent(Unknown Source)
      at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
      at java.awt.EventQueue.access$200(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
      Source)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
      Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
      Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

        Activity

        Hide
        Patrick Corless added a comment -

        The reason for the null point is that the font's WeakReference is getting garbage collected even though there appears to be a hard reference to the same object in the StateManager class.

        Show
        Patrick Corless added a comment - The reason for the null point is that the font's WeakReference is getting garbage collected even though there appears to be a hard reference to the same object in the StateManager class.
        Hide
        Patrick Corless added a comment -

        I think I've narrowed down the problem. We recreate the font object every time the annotation is edited and put the new object in the StateManager but at this time we don't update the library and the thus the font resource is available for garbage collection. I've reworded the resetAppearanceStream() method to first always register the hard reference with he call.

        stateManager.addChange(new PObject(newFont, newFont.getPObjectReference()));

        Followed by the setup of the library weak reference.

        library.addObject(newFont, newFont.getPObjectReference());

        I'm unable to reproduce the issue now after a forced garbage collection.

        Show
        Patrick Corless added a comment - I think I've narrowed down the problem. We recreate the font object every time the annotation is edited and put the new object in the StateManager but at this time we don't update the library and the thus the font resource is available for garbage collection. I've reworded the resetAppearanceStream() method to first always register the hard reference with he call. stateManager.addChange(new PObject(newFont, newFont.getPObjectReference())); Followed by the setup of the library weak reference. library.addObject(newFont, newFont.getPObjectReference()); I'm unable to reproduce the issue now after a forced garbage collection.
        Hide
        Patrick Corless added a comment -

        Checked in fix into 5.0.1 branch and trunk.

        Show
        Patrick Corless added a comment - Checked in fix into 5.0.1 branch and trunk.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: