Results 1 to 20 of 21
Thread: Java Heap Space Error...
- 03-11-2013, 11:00 PM #1
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Java Heap Space Error...
Hi All
This is the error I'm getting. It happens when I'm trying to create a 6 dimensional array...
I've changed my config and the properties for the project:
netbeans_default_options="-J-client -J-Xmx1600M -J-Xss2m -J-Xms512m -J-XX:PermSize=500m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
but still I get...
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Any ideas?
- 03-11-2013, 11:26 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
Just one. Post your code (and please encapsulate your code between code tags [code][/code]).
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-11-2013, 11:35 PM #3
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: Java Heap Space Error...
Java Code:String[][][][][][] DATA; ArrayList One = new ArrayList(); ArrayList Two = new ArrayList(); ArrayList Three = new ArrayList(); ArrayList Four = new ArrayList(); ArrayList Five = new ArrayList(); ArrayList Six = new ArrayList(); public static void main(String[] args) throws FileNotFoundException { new Properties(); } public Properties() throws FileNotFoundException { LoadData(); DATA = new String[One.size()][Two.size()][Three.size()][Four.size()][Five.size()][Six.size()]; DatatoDimension(); } public void LoadData() throws FileNotFoundException { File P = new File("Properties.txt"); Scanner in = new Scanner(P); String Info = (String)in.nextLine(); while (in.hasNext()) { String Line = (String)in.nextLine(); String[] Content = Line.split(" "); System.out.println(" "); One.add((String)Content[0]); Two.add((String)Content[1]); Three.add((String)Content[2]); Four.add((String)Content[3]); Five.add((String)Content[4]); Six.add((String)Content[5]); } in.close(); } public void DatatoDimension() { // START 1 for(int i=0; i< DATA.length;i++) { DATA[i][0][0][0][0][0] = (String)(One.get(i)); // START 2 { for(int j=0; j< DATA[i].length;j++) { DATA[i][j][0][0][0][0] = (String)(One.get(i)); // START 3 for(int k=0; k< DATA[i][j].length;k++) { DATA[i][j][k][0][0][0] = (String)(One.get(i)); // START 4 for(int l=0; l< DATA[i][j][k].length;l++) { DATA[i][j][k][l][0][0] = (String)(One.get(i)); // START 5 for(int m=0; m< DATA[i][j][k][l].length;m++) { DATA[i][j][k][l][m][0] = (String)(One.get(i)); // START 6 for(int n=0; n< DATA[i][j][k][l][m].length;n++) { DATA[i][j][k][l][m][n] = (String)(One.get(i)); } } } } } } } }
- 03-11-2013, 11:36 PM #4
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: Java Heap Space Error...
Perhaps my approach is redundant, not too sure... I'm trying to implement a 6 dimension data cube
DATA = new String[One.size()][Two.size()][Three.size()][Four.size()][Five.size()][Six.size()];
It doesn't get past that line... so entering data isn't even reached.
Edit: If you'd like to test the sizes, each Dimension is 999.
- 03-11-2013, 11:42 PM #5
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
It compiles but since I don't have your property file I can't determine what the problem would be. Can you please describe what it is you are trying to do?
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-11-2013, 11:55 PM #6
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: Java Heap Space Error...
The property file contains 998 or 999 lines of data.
Suburb Type Nr Rooms Nr Baths Nr Parking Sqr Met Price
X X X X X X X
I want to load this into a 6 dimension datacube.
I'm reading from a textfile and attempting to load it into the Cube.
The problem is, my program won't even create the 6dimension array of size 998, so it doesn't even
reach the code that extracts the data.
Many thanks for your time.
- 03-12-2013, 12:19 AM #7
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
Well, I would be remiss if I didn't suggest an easier approach. Why not create another class which holds your property values. Then just use a List to hold instances of the class. Of course, I may be missing something. Is there something special you are doing where you require a 6 dimensional array?
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-12-2013, 12:25 AM #8
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: Java Heap Space Error...
Thanks for the input :) I'm trying to create a "Data Cube" so that drill downs and various data mining techniques can be used...
- 03-12-2013, 01:43 AM #9
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
I just noticed something from an earlier post of yours. You said that each array is 999. That is the problem! A two dimensional array of 1000 x1000 contains 1,000,000 elements. Yours contains something on the order of 1000^6 or 1 million trillion. It ain't gonna work!Perhaps my approach is redundant, not too sure... I'm trying to implement a 6 dimension data cube
DATA = new String[One.size()][Two.size()][Three.size()][Four.size()][Five.size()][Six.size()];
It doesn't get past that line... so entering data isn't even reached.
Edit: If you'd like to test the sizes, each Dimension is 999.
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-12-2013, 03:24 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Heap Space Error...
I always have to think when I read things like the above: in Dutch (and Britsh English) we use million, milliard, billion, billiard, trillion, trilliard etc. but the tribes on the other side of the pond just use million, billion. trillion etc. it must be something in their drinking water ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-12-2013, 03:35 PM #11
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
I have actually never heard of milliard, billiard, trilliard. I could have said 10^18. And I was too lazy to lookup one quintillion.
Proost!
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-12-2013, 03:42 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
- 03-12-2013, 04:48 PM #13
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Heap Space Error...
That's because you live on the wrong side of the pond and we live on the right side; so there! ;-P I suspect it's because of Webster and his silly language 'simplification' syndrome ...
Zit ie potdoppie nu alweer aan de drank ...
kind regards,
Jos ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-12-2013, 06:12 PM #14
- 03-12-2013, 06:37 PM #15
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Heap Space Error...
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-12-2013, 06:52 PM #16
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 670
- Rep Power
- 1
Re: Java Heap Space Error...
Don't you know? It's not booze. It's that nasty American water. :)
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-12-2013, 09:49 PM #17
Re: Java Heap Space Error...
Eau de Americana?
Why do they call it rush hour when nothing moves? - Robin Williams
- 03-14-2013, 07:51 PM #18
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: Java Heap Space Error...
Thanks for the advice. Yeah turns out my array is now 3x2x6x6x4x5 or something. I have a different problem now...
When I iterate through the monster array and display it's contents, I end up with duplicate values being displayed. I'm not sure if it's because I've added duplicate values to the Arrays, although
I'm pretty sure I'm didn't. I explicitly add 999 values. When I iterate through it, I land up with 2322 or so.
Any ideas? It seems right...Java Code:for(int i=0; i< DATA.length;i++) { Sum += DATA[i][0][0][0][0][0].Sum; Count += DATA[i][0][0][0][0][0].Count; DATA[i][0][0][0][0][0].DisplayItems(); // START 2 { for(int j=0; j< DATA[i].length;j++) { Sum += DATA[i][j][0][0][0][0].Sum; Count += DATA[i][j][0][0][0][0].Count; DATA[i][j][0][0][0][0].DisplayItems(); // START 3 for(int k=0; k< DATA[i][j].length;k++) { Sum += DATA[i][j][k][0][0][0].Sum; Count += DATA[i][j][k][0][0][0].Count; DATA[i][j][k][0][0][0].DisplayItems(); // START 4 for(int l=0; l< DATA[i][j][k].length;l++) { Sum += DATA[i][j][k][l][0][0].Sum; Count += DATA[i][j][k][l][0][0].Count; DATA[i][j][k][l][0][0].DisplayItems(); // START 5 for(int m=0; m< DATA[i][j][k][l].length;m++) { Sum += DATA[i][j][k][l][m][0].Sum; Count += DATA[i][j][k][l][m][0].Count; DATA[i][j][k][l][m][0].DisplayItems(); // START 6 for(int n=0; n< DATA[i][j][k][l][m].length;n++) { Sum += DATA[i][j][k][l][m][n].Sum; Count += DATA[i][j][k][l][m][n].Count; DATA[i][j][k][l][m][n].DisplayItems(); } } } } } } }
- 03-16-2013, 02:37 AM #19
Senior Member
- Join Date
- Oct 2012
- Posts
- 108
- Rep Power
- 0
Re: Java Heap Space Error...
See my comments next to Sum += lines above.... much simpler example:
Java Code:int sum = 0; int[][] thing = new int[10][10]; for(int ii = 0; ii < 10; ii++){ for(int jj=0; jj < 10; jj++){ thing[ii][jj] = 1; sum+=1; } } System.out.println(sum); sum = 0; for(int i = 0; i < 10; i++){ sum += thing[i][0]; //sum += thing[0][0] on first iteration for(int j = 0; j < 10; j++){ sum += thing[i][j]; //sum += thing[0][0] on first iteration } } System.out.print(sum);
- 03-16-2013, 11:42 PM #20
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Java Heap Space Error
By wanna learn more :) in forum Advanced JavaReplies: 3Last Post: 03-26-2012, 12:35 PM -
Java Heap space error using ArrayList.
By AcousticBruce in forum New To JavaReplies: 13Last Post: 01-03-2011, 01:06 PM -
how to solve this ERROR --java.lang.OutOfMemoryError: Java heap space
By krunalpatel1410 in forum New To JavaReplies: 5Last Post: 08-13-2010, 10:04 AM -
java out of memory error-heap space error
By elsanthosh in forum NetBeansReplies: 4Last Post: 06-15-2010, 09:31 AM -
Java heap space error
By gezzel in forum New To JavaReplies: 19Last Post: 09-25-2008, 12:07 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks