Hello everyone,

I'm facing a "java.lang.OutOfMemoryError: GC overhead limit exceeded" error
and I would like an advice about how I could optimize my code.

The aim of this method is to run a SPARQL query, convert it on a XML format
and then apply a XSL stylesheet[1] to write a JSON format (readable by
Exhibit - Scripted [2]).

 My piece of code was working well untill today. (I have been trying to
query a big model and the query returns too much results).
This makes my program break.

<quote>
Query queryToExec = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.create(queryToExec, ontoIn);
 ResultSet result = null;
BufferedOutputStream buf;
try{
 result = qexec.execSelect();
buf = new BufferedOutputStream(new FileOutputStream(new File(root +
"XML/JSON_XML/"+qNameClass+".xml")));
 //Serialization of the resultSet
ResultSetFormatter.outputAsXML(buf, result);
buf.close();
 }
catch (Exception e) {
e.printStackTrace();
 }
finally{
qexec.close();
}
</quote>

I know that writing XML file use loads memory....

I was thinking of:
 - creating several XML files by tracing the ResullSetFormatter memory
usage. (is there possible?)
 - avoiding XML intermediate format and write directly in one or several
JSON file...
 - ...


>  Is there someone whom find a way to avoid this kind of error (without
increasing Xms Xmx) ??

Thanks in advance,


Brice

[1] http://data-gov.tw.rpi.edu/wiki/Sparqlxml2exhibitjson.xsl
[2] http://www.simile-widgets.org/exhibit3/

Reply via email to