Thanks. The StreamingParser works considerably better (if a little 
slower). Note that the xPath expression must be "//featureMember" 
(without the prefix).

I also tried "Alternative 2: Ignoring the Application Schema", but this 
didn't work. I get

org.xml.sax.SAXException: Handler for wfs:FeatureCollection could not be 
found.
        at 
org.geotools.xml.impl.ParserHandler.startElement(ParserHandler.java:357)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown 
Source)
        at ...

I don't understand why the parser requires a handler for 
"wfs:FeatureCollection" if I tell it to ignore the schema? When I use 
the WFSConfiguration (which I created for WFS feature collections) 
instead of GMLConfiguration, I get the same exception for the 
application schema type, i.e. test:TestFeature in the example.

Any ideas?

Cheers,
Michael


Justin Deoliveira wrote:
> Hi Michael,
> 
> I suggest for any reasonable size dataset you use the StreamingParser:
> 
> StreamingParser parser =
>    new StreamingParser(configuration,"//gml:featureMember");
> 
>    try{
>      Feature f = null;
>      while ( ( f = parser.parse() ) != null ) {
>         ...
>      }
> 
>    }...
> }
> 
> Some more info about streaming here:
> 
> http://docs.codehaus.org/display/GEOTDOC/GML+XML+Support
> 
> -Justin
> 
> Michael Lutz wrote:
>> We are running into big memory problems when trying to parse large GML 
>> files containing WFS feature collections (e.g. 25000 points, about 25MB 
>> as GML) using the following code:
>>
>> public static FeatureCollection readFromInputStream(InputStream in) {
>>    Configuration configuration  = new WFSConfiguration();
>>    Parser parser = new Parser(configuration);
>>    try{
>>      FeatureCollection fc = (FeatureCollection) parser.parse( in );
>>      in.close();
>>      return fc;
>>    } ...
>> }
>>
>> For this example, the used memory goes up to 800MB. After the parsing, 
>> it goes down again to around 60MB.
>>
>> Any ideas why this is, and where we should be looking for memory leaks?
>>
>> Cheers,
>> Michael
>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Geotools-devel mailing list
>> Geotools-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>
>> !DSPAM:1004,45dc87ae102861460912952!
>>
> 
> 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to