xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 53046] image session context lacks control over retained sources leading to excessive memory usage by image sources
Date Wed, 11 Apr 2012 15:19:12 GMT

--- Comment #3 from Dominik Stadler <dominik.stadler@gmx.at> 2012-04-11 15:19:12 UTC
I have worked around this via the following helper method which iterates over
any image that was used for creating a PDF with FOP and tries to get the
related source and closes it.

    public static void cleanupFOAgentImages(final Collection<String> images,
final FOUserAgent foUserAgent) {
        for(String image : images) {
            if(logger.isLoggable(Level.FINE)) {
                logger.fine("Try to remove file: file:///" + image + " from FOP
image session context."); //$NON-NLS-1$ //$NON-NLS-2$

            ImageSessionContext imageCtx =
            if(imageCtx instanceof AbstractImageSessionContext) {
                AbstractImageSessionContext aImageCtx =
                Source src = aImageCtx.getSource(BaseConstants.FILE_PROTOCOL +

                // use helper method which does the correct close for all types
of Source, e.g. StreamSource, ImageSource, ...
                // this also handles src==null gracefully.

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

View raw message