Skip to main content

OutOfMemoryError

2 replies [Last post]
sarath44
Offline
Joined: 2007-05-14

Hi,
I'm reading the integer data that is present in a .txt file and upon reading it I'm doing some compution. My program is working well and gud for small amount of data in the file, but when i'm trying to read large of amount of data that is present in the file I'm getting the below mentioned error.

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap spa
ce
at DataAnalysis.kohonen(DataAnalysis.java:472)
at DataAnalysis.readfile(DataAnalysis.java:376)
at DataAnalysis$submit.actionPerformed(DataAnalysis.java:215)
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 Sour
ce)
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.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

The thing that I couldn't able to get is when I'm checking at the lines 472; 376; 215 in my code, those lines are blank lines which dont have any code. I couldn't able to know like what went wrong and where i went wrong.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ken Warner

Having just beat my head against a virtual brick wall for the last few days, I think I can help.

Take a look at:

http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html

In particular, note these arguments about 3/4 of the way down the page.

-Xmsn
Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 2MB. Examples:

-Xms6291456
-Xms6144k
-Xms6m

-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. Examples:

-Xmx83886080
-Xmx81920k
-Xmx80m
-Xms256M will set the initial swap space to 256 meg.

-Xmx512M will set the maximum memory size to 512 meg.

Use numbers appropriate for your computer. How you set the JVM arguments will
depend on how you have your enviroment configured. I can't help you there.

Also, try starting a separate thread to do your data analysis. You are running your data analysis in
the AWT event thread. Best to just start a separate thread in your actionedPerformed handler and let go of the AWT event thread.

Ken

java2d@JAVADESKTOP.ORG wrote:
> Hi,
> I'm reading the integer data that is present in a .txt file and upon reading it I'm doing some compution. My program is working well and gud for small amount of data in the file, but when i'm trying to read large of amount of data that is present in the file I'm getting the below mentioned error.
>
> Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap spa
> ce
> at DataAnalysis.kohonen(DataAnalysis.java:472)
> at DataAnalysis.readfile(DataAnalysis.java:376)
> at DataAnalysis$submit.actionPerformed(DataAnalysis.java:215)
> 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 Sour
> ce)
> 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.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
>
>
>
> The thing that I couldn't able to get is when I'm checking at the lines 472; 376; 215 in my code, those lines are blank lines which dont have any code. I couldn't able to know like what went wrong and where i went wrong.
> [Message sent by forum member 'sarath44' (sarath44)]
>
> http://forums.java.net/jive/thread.jspa?messageID=227518
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

dany111
Offline
Joined: 2005-11-06

Hi.

Did you tried to increase the Memory of the Virtual Machine using the command -XmxNNNm?

Where NNN is the max amount of memory you want to set.
As an instance, -Xmx256m ....... -Xmx512m