ICEpdf
  1. ICEpdf
  2. PDF-68

Resources reference counting

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1.1, 4.0 - Beta, 4.0
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      none

      Description

      Resources objects are used by Page, PageTree, Form, ContentParser. Multiple Page objects can share the same Resources object, meaning that the first Page can initialise the Resource object, and then when loading the second Page (in a low memory scenario), it may run out of memory, and ask the MemoryManager to free memory, which will cause the first Page to dispose, which will dispose the shared Resources, while the second Page is trying to make use of it. In that scenario we want to avoid disposing the Resources.

      On the other hand, Form and ContentParser objects can temporarily make use of Resources objects, to create Shapes objects, which get passed up the stack to a Page object. When the ContentParser parses the input stream, and generates Shapes, if it made some of the Shapes via a Form, then it leaves that Form intact, and doesn't reclaim its memory. Which makes sense, since it can't dispose of the Shapes, since it's passing them up to whoever invoked its parse() method. Later, if we dispose of the Page, and re-init it, the ContentParser will lookup that Form again, and find it already initialized from before, since there is no hook to cleaning up a Form from within a ContentParser. In this case, we want to immediately cleanup the Resources from the Form.

      Both scenarios benefit from reference counting on the Resources objects, to better manage deferring or immediately cleaning up the Resources.

        Activity

        Hide
        Patrick Corless added a comment -

        Marks comment on the case:

        In my code, when the ContentParser is done with the Form, I null everything out in the Form itself. Then, if the Page reduces it memory, I made it so that Shapes will recursively dispose. I think this will allow for clearing more memory. Then, when the Page re-initis, and the ContentParser does its parse(), the Form is not in a pre-initialised state, and has to set itself up again.

        My Comments:

        This seems to work well and the overall cost of reparsing the form data is quite low. I'll back bord this to the 3.1 branch for a 3.11 release.

        Show
        Patrick Corless added a comment - Marks comment on the case: In my code, when the ContentParser is done with the Form, I null everything out in the Form itself. Then, if the Page reduces it memory, I made it so that Shapes will recursively dispose. I think this will allow for clearing more memory. Then, when the Page re-initis, and the ContentParser does its parse(), the Form is not in a pre-initialised state, and has to set itself up again. My Comments: This seems to work well and the overall cost of reparsing the form data is quite low. I'll back bord this to the 3.1 branch for a 3.11 release.
        Hide
        Patrick Corless added a comment -

        Fixed.

        Show
        Patrick Corless added a comment - Fixed.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: