Simple ODS, OutOfMemoryError: Java heap space on save file
<p>I get this error "OutOfMemoryError: Java heap space", when save a file with 1500 rows or more.</p>

<p>I try solve this split the list data</p>

<p>I tried to solve this split data list into smaller parts and save and load the ods file. I use de function insertRowsBefore to append new rows. But its not work for me. When save load the table, append new row list and save, the save function save a full table again and I get the error. My rows has thirty-five columns</p>

<p>I try to use this versions:</p>

<pre><code>&lt;dependency&gt;
&lt;groupId&gt;org.odftoolkit&lt;/groupId&gt;
&lt;artifactId&gt;simple-odf&lt;/artifactId&gt;
&lt;version&gt;0.6.6&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>and</p>

<pre><code>&lt;dependency&gt;
&lt;groupId&gt;org.apache.odftoolkit&lt;/groupId&gt;
&lt;artifactId&gt;simple-odf&lt;/artifactId&gt;
&lt;version&gt;0.7-incubating&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>Error details:</p>

<pre><code>13:45:12,821 INFO [stdout] Excepción: java.lang.OutOfMemoryError: Java heap space 
13:45:12,822 INFO [stdout] (asyncExecutor-1) at java.util.Arrays.copyOf(Arrays.java:2271) 
13:45:12,822 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
13:45:12,822 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
13:45:12,822 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
13:45:12,823 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
13:45:12,823 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
13:45:12,823 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125) 
13:45:12,823 INFO [stdout] (asyncExecutor-1) at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
13:45:12,823 INFO [stdout] (asyncExecutor-1) at java.io.Writer.write(Writer.java:127)
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.Printer.printText(Unknown Source)
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.XMLSerializer.printAttribute(Unknown Source)
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown Source) 
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source) 
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown Source) 
13:45:12,824 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source) 
13:45:12,825 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown Source) 
13:45:12,825 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source) 
13:45:12,825 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source) 
13:45:12,825 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.BaseMarkupSerializer.serialize(Unknown Source) 
13:45:12,826 INFO [stdout] (asyncExecutor-1) at org.apache.xml.serialize.DOMSerializerImpl.write(Unknown Source)
13:45:12,826 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.odfdom.pkg.OdfPackage.flushDom(OdfPackage.java:1626)
13:45:12,826 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.odfdom.pkg.OdfPackage.getBytes(OdfPackage.java:1566)
13:45:12,826 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.odfdom.pkg.OdfPackage.save(OdfPackage.java:877)
13:45:12,827 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.odfdom.pkg.OdfPackage.save(OdfPackage.java:823)
13:45:12,827 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.simple.Document.save(Document.java:728) 
13:45:12,827 INFO [stdout] (asyncExecutor-1) at org.odftoolkit.odfdom.pkg.OdfPackageDocument.save(OdfPackageDocument.java:228)
</code></pre>

<p>Log for my custom functions and services </p>

<pre><code>13:45:12,828 INFO [stdout] (asyncExecutor-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
13:45:12,828 INFO [stdout] (asyncExecutor-1) | java.lang.OutOfMemoryError: Java heap space 
13:45:12,828 INFO [stdout] (asyncExecutor-1) at java.util.Arrays.copyOf(Arrays.java:2271)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
13:45:12,828 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
13:45:12,829 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
13:45:12,829 INFO [stdout] (asyncExecutor-1) at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
13:45:12,829 INFO [stdout] (asyncExecutor-1) at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
13:45:12,829 INFO [stdout] (asyncExecutor-1) at java.io.Writer.write(Writer.java:127)
</code></pre>

<p>My export code:</p>

<pre><code>public static &lt;T&gt; void export(String[] columnTitle, List&lt;T&gt; data, String[] fields, String path, String filename) throws Exception {

    try {
        SpreadsheetDocument ods = SpreadsheetDocument.newSpreadsheetDocument();
        ods.removeSheet(0);

        Table table = Table.newTable(ods, data.size() + MagicNumber.TWO, columnTitle.length, 0, 0);
        table.setTableName(filename);
        String[] values = new String[fields.length];
        int line = 0;

        Border border = new Border(Color.BLACK, BORDER_WIDTH, StyleTypeDefinitions.SupportedLinearMeasure.PT);

        List&lt;Row&gt; rows = table.getRowList();

        Row r = rows.get(line);
        Cell cell = r.getCellByIndex(0);

        //Style for column title
        Font font = new Font(ARIAL_FONT, FontStyle.BOLD, MagicNumber.SEVEN, Color.BLACK);
        r = rows.get(line);
        for (int a = 0; a &lt; fields.length; a++) {
            cell = r.getCellByIndex(a);
            cell.setStringValue(columnTitle[a]);
            cell.setBorders(CellBordersType.ALL_FOUR, border);
            cell.setCellBackgroundColor(Color.valueOf("#A5A5A5"));
            cell.setFont(font);
            cell.setHorizontalAlignment(HorizontalAlignmentType.CENTER);
        }

        //write data
        font = new Font(ARIAL_FONT, FontStyle.REGULAR, MagicNumber.SEVEN);
        for (T obj : data) {
            line++;
            r = rows.get(line);
            for (int i = 0; i &lt; fields.length; i++) {
                cell = r.getCellByIndex(i);
                values[i] = getProperty(obj, fields[i]);
                cell.setStringValue(String.valueOf(values[i]));
                cell.setBorders(CellBordersType.ALL_FOUR, border);
                cell.setFont(font);
                cell.setHorizontalAlignment(HorizontalAlignmentType.RIGHT);
            }
        }

        //Error with 2000 results
        ods.save(path);

    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        LOG.error(e);
    } catch (Exception e) {
        LOG.error(e);            
    }
}
</code></pre>