mapfish / mapfish-print

A component of MapFish for printing templated cartographic maps. This module is the Java serverside module.
http://mapfish.github.io/mapfish-print-doc/
BSD 2-Clause "Simplified" License
185 stars 417 forks source link

Memory leak in some cases #677

Open pvalsecc opened 6 years ago

pvalsecc commented 6 years ago

The profiler tends to show a huge amount of objects in relation with XML schema caches deep down within dependencies of GeoTools.

The suspect is a layer with a SLD and a filter:

...
            },{
                "type": "GML",
                "name": "zoom",
                "url": "http://mapserver/mapserv?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAMES=agri_parcels_print,agri_parcels_finished_print&FILTER=%28%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Eid%3C/PropertyName%3E%3CLiteral%3E${exchangeProperty.parcelId}%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%29%28%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Eid%3C/PropertyName%3E%3CLiteral%3E${exchangeProperty.parcelId}%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%29",
                "style": "no_display"
            }],
            "projection": "EPSG:2056",
            "rotation": 0
        },
        "scale": 80000,
        "style": {"style": '<?xml version="1.0" encoding="UTF8"?><StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <NamedLayer><Name>no_display</Name><UserStyle><Title>Default Line</Title><FeatureTypeStyle></FeatureTypeStyle> </UserStyle> </NamedLayer></StyledLayerDescriptor>'}
    },
    "layout": "A4 portrait ${exchangeProperty.canton}"
}

The current, but very ugly work around is to add those to CATALINA_OPTS (works only if you have something restarting your web server):

-XX:GCTimeLimit=70 -XX:GCHeapFreeLimit=5  -XX:+ExitOnOutOfMemoryError

Some prints will fail, but the print at least restarts.

Example with restarts

svavoi commented 4 years ago

We noticed the same and analyzed it. It seems, that XCDElementDeclarationImpl objects add up. They are referenced through the schema in the GML (XSD) sigleton from the GeoTools and they reference to one another so they are never garbage collected. @FrediWeber

pvalsecc commented 4 years ago

Yeah, I've seen problems in that area too, but never really found the culprit. Can you create a ticket in geotools, please?

danduk82 commented 4 years ago

@svavoi do you have some test data/layers that reproduce this problem that I can use? I am trying to dig into this. Thanks in advance

pvalsecc commented 4 years ago

Hi Andrea. You can reproduce it with the batch prints of agridea.

Le 25 mai 2020 14:31:21 Andrea Borghi notifications@github.com a écrit :

@svavoi do you have some test data/layers that reproduce this problem that I can use? I am trying to dig into this. Thanks in advance— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

danduk82 commented 4 years ago

@pvalsecc thanks for the hint ;)