Results 1 to 11 of 11
- 04-09-2009, 08:03 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 24
- Rep Power
- 0
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
Hi,
I have a small doubt that by adding an variable of type 2-dimensional array it is giving the OutOfMemoryError. In my code I am using almost using the arrays. By continuing this process after adding a one more 2-dim array variable it is giving the above error. How it could be and How can I solve this problem.
Regards,Java Code:public class SocialNetworkCons { CommunicationNetworkId[] networkIds = { new CommunicationNetworkId("Academics") }; AcademicsAgents agent[]=new AcademicsAgents[500]; Author author[]=new Author[1000]; ReadingInput input=new ReadingInput(); static int m=0,n=0,j; int p,r,temp,authorId,articleId=-1; int neighborsList[][]=new int[1000][1000]; int weightBetweenAuthors[][]=new int[1000][1000]; float weightBetweenAuthorNArticle[][]=new float[1000][1000]; int edgeBetweenAuthorNArticle[][]=new int[1000][1000]; int authorsId[]=new int [20]; float threshold[]=new float[5000]; ArrayList Hits = new ArrayList(); int noOfAuthors=-1; float refEdge[][]=new float[1000][1000]; int coAuthors[][]=new int[1000][1000]; // by simply including this variable it is giving OutOfMemoryError. ............ ......... // some code }
vasavi
- 04-09-2009, 11:02 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What's the purpose of using this much of arrays in your application? Even Java follows automatic garbage collection, no wonder there could be a memory leak anyway.
- 04-09-2009, 11:59 AM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
As said in the last post its a memory leak situation or it requires more than the default memory 128 mb, so you might want to increase the heap space.
Increase heap size in Java to prevent java.lang.OutOfMemoryError
- 04-09-2009, 04:46 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 04-16-2009, 08:10 AM #5
Member
- Join Date
- Feb 2009
- Posts
- 24
- Rep Power
- 0
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
Hi friends,
Thank You for your valuable suggestions. I am a PG student doing the project in final year. My application (project) has to create a large network having many nodes and establishing the connections between the nodes dynamically both nodes as well as edges between them. I am new to java. So I took the help of arrays. The number of nodes are unknown to us initially that's why I created a large size of arrays. That was the reason for creating the arrays of size 1000.
By viewing previous post I found that, if there is no more memory to create new objects then JVM throws an exception. I will explain the application what I am doing.
I have to store a new article information and as well as its author Information. For that I created an array of objects of size 500 and 1000 respectively (we don't know the count of articles and authors initially). Constructing a network based on the data which is stored in a file. And passing this network to different methods to see the results. It is working well using console. I am trying it to convert a GUI.
Main.java is a file in which I am creating an object for the homepage.java and calling it. From there I kept a ok and cancel button. On pressing ok button it has to go to other window in which article information has to enter. Again on validating the information it has to accept the author information (it may be 1 or more than one it depends on the data entered by a user). All this information is stored in a file (acts as a database). Using the data stored in a file the other method in a java program creates a network and passing it to different methods. Till know it is working well. I would like to consider some other criterias and checking how this methods are working. For that I created an arrays coAuthors of size 1000X1000. Just by creating an array it is giving the OutOfmemory exception before adding this variable it is working well.
Coming to objects all are interlinked. Because on clicking ok only it has to goto other window. Up to my knowledge there is no way to call the methods in Main.java on clicking the ok button. In my aspect all object are in the active state. Now also I am not trying to create new objects. Why this exception is raised I am not getting the point.
I also tried to increase the heapsize it is giving the invalid initial size and max size. I am using Linux platform. I don't know how to get the initial heap size and upto what extend i can increase the size.
I used the command java -Xms32mb -Xms128mb
The error it is giving is Invalid initial heap size: -Xms32mb
Could not create the Java virtual machine.
Please respond fast.
Regards,
vasavi
- 04-16-2009, 08:33 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Try command java -Xms128mb and see.
- 04-16-2009, 08:51 AM #7
If you don't know how big your arrays will be, use Vectors or other Collections in java.util. They will automatically grow to accommodate new elements.
It's probably better to keep information in persistant storage - files or even better an actual database - and only load it into memory when you actually need it.
If you do these you probably won't run out of memory.Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 05-11-2009, 07:47 AM #8
Member
- Join Date
- Sep 2008
- Posts
- 43
- Rep Power
- 0
Hi mate,
I too have written a program that requires the use of very large arrays and I ran into the same problem. Don't know if this post has been solved yet but I increased my java heap size considerably and just used
-Xms128m -Xmx1024m
Using 32 and 128 as your min and max doesn't seem large enough.
- 05-11-2009, 09:52 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 05-11-2009, 10:25 AM #10
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
You give your app a max of 1GB, 2potatocakes? xD that's one hell of an application then. ;)
I die a little on the inside...
Every time I get shot.
- 05-11-2009, 11:56 AM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Most of the clients are like to use light weight applications normally. If your application going to use lots of memory in your system, it's a heck lol.
Similar Threads
-
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException:
By satishkumar_lskin in forum AWT / SwingReplies: 2Last Post: 12-14-2009, 01:46 AM -
[SOLVED] pls help :S . "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerE
By ara in forum New To JavaReplies: 10Last Post: 01-29-2009, 08:00 AM -
Wanted help on "java.lang.OutOfMemoryError: Java heap space"
By itmani2020 in forum EclipseReplies: 16Last Post: 07-24-2008, 11:45 AM -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
By Eku in forum NetBeansReplies: 14Last Post: 06-12-2008, 08:36 AM -
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
By hemanthjava in forum AWT / SwingReplies: 3Last Post: 01-29-2008, 01:37 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks