If you're just looking to parse a GML geometry and not a complete "application schema", try using the very simple streaming parser:

https://docs.geotools.org/stable/userguide/unsupported/gml-geometry-streaming.html

It is a lot faster than the XSD based parser, especially if you use the Aalto or Woodstox XML parser.

Matthijs

On 21/04/2023 13.46, gero.will...@gmx.net wrote:

Hello togehter,

my usecase is using method StreamingParser.parse()  in a loop in my java application (ca. 5000 iterations). Unfortunately this leads to a huge memory leak. Also this memory can never be released by the garbage collector. It stays in the old gen heap forever.

I use

https://github.com/geotools/geotools/blob/main/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xsd/StreamingParser.java


in this way:

for(.....) {
     try {
             org.geotools.xsd.StreamingParser parser  = new 
org.geotools.xsd.StreamingParser(gml, inputStream, Polygon.class);
             polygon = (Polygon) parser.parse();
     } finally {
             inputStream.close();
     }
}



Do you have any idea why that happens? Are you even able to fix it?


I use the following maven dependency:

<dependency>
     <groupId>org.geotools.xsd</groupId>
     <artifactId>gt-xsd-wfs</artifactId>
     <version>27.2</version>
</dependency>



Best regards,

Gero



_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to