处理记录所需的堆内存大小

时间:2019-02-05 06:56:11

标签: eclipse heap-memory

我正在处理在Eclipse中有100万条记录的数据。我已将堆内存从-xmas 256m增加到-xmas 512m和-xmax 1024m到-xmax 2048m。仍然内存不足错误如下:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java 
heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuffer.append(Unknown Source)
at java.io.StringWriter.write(Unknown Source)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1129)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1104)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1050)
at org.apache.commons.io.IOUtils.toString(IOUtils.java:359)
at WorkSpot.Ftp.getmfebcdata(Ftp.java:372)
at WorkSpot.ParseData.parsetolines(ParseData.java:112)
at WorkSpot.SheetFormat.getsheet(SheetFormat.java:55)
at WorkSpot.MainScreen$1.actionPerformed(MainScreen.java:492)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown 
Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

请帮助我解决此问题。

2 个答案:

答案 0 :(得分:1)

您使用了错误的开关,需要-Xms-Xmx。例如,-Xmx1024m,请注意也没有空格。有关开关的更多信息,请参见this link

答案 1 :(得分:1)

eclipse.ini设置会更改Eclipse本身使用的内存,而不会更改您从Eclipse内部运行的程序的内存设置。很少需要更改此文件。

要更改程序的设置,请打开“运行>运行配置”对话框。

在“ Java应用程序”部分中找到程序配置。

在“参数”选项卡上,将“ -Xms”和“ -Xmx”设置放在“虚拟机参数”部分。