私はこのエラーを取得する「Javaヒープ・スペースのOutOfMemoryError」を保存上のJavaヒープ領域。シンプルODS、OutOfMemoryErrorが発生:1500行以上でファイルを保存するとき、:ファイル
私は小さな部分に、この分割されたデータリストを解決し、ODSファイルを保存してロードしようとしたリストデータ
このスプリットを解決してみてください。私は新しい行を追加するために関数insertRowsBeforeを使用します。しかし、それは私のために働かない。テーブルを保存して保存すると、新しい行のリストを追加して保存します。保存すると、テーブル全体が再び保存され、エラーが発生します。私の行は、32 5列
を持っている私は、このバージョンを使用してみてください:
<dependency>
<groupId>org.odftoolkit</groupId>
<artifactId>simple-odf</artifactId>
<version>0.6.6</version>
</dependency>
と
<dependency>
<groupId>org.apache.odftoolkit</groupId>
<artifactId>simple-odf</artifactId>
<version>0.7-incubating</version>
</dependency>
エラーの詳細:
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)
ログ私のカスタム機能やサービスについて
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)
マイ輸出コード:
public static <T> void export(String[] columnTitle, List<T> 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<Row> 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 < 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 < 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);
}
}
コードサンプルを投稿できますか?あなたのコードを見ることができれば、問題を手助けする方がはるかに簡単です。 – slarge
私のカスタムエクスポートコードで編集@slarge – oscar
getProperty(obj、fields [i])とは何ですか?それは何を取得するのですか?私は20000行を書きました。自分のサンプルはあなたのものをベースにしています。 – slarge