Page 1 of 2 12 LastLast
Results 1 to 20 of 21
Like Tree1Likes

Thread: Java Heap Space Error...

  1. #1
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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?

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default Re: Java Heap Space Error...

    Just one. Post your code (and please encapsulate your code between code tags [code][/code]).

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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));
    
                                    }
    
    
                                }
    
                            }
                        }
                     }
              }
          }
        }

  4. #4
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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.

  5. #5
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default 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,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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.

  7. #7
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default 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,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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...

  9. #9
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default 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.
    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!

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,786
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java Heap Space Error...

    Quote Originally Posted by jim829 View Post
    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!
    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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  11. #11
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default 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!
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Java Heap Space Error...

    Quote Originally Posted by jim829 View Post
    I have actually never heard of ... billiard, .... I could have said 10^18. And I was too lazy to lookup one quintillion.

    Proost!
    Jim
    It's a pool-like game using 3 balls...
    DarrylBurke likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,786
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java Heap Space Error...

    Quote Originally Posted by jim829 View Post
    I have actually never heard of milliard, billiard, trilliard. I could have said 10^18. And I was too lazy to lookup one quintillion.
    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 ...

    Quote Originally Posted by jim829 View Post
    Proost!
    Jim
    Zit ie potdoppie nu alweer aan de drank ...

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Java Heap Space Error...

    Quote Originally Posted by JosAH View Post
    Zit ie potdoppie nu alweer aan de drank ...
    Shouldn't that be grolsch de drank? ;)
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,786
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java Heap Space Error...

    Quote Originally Posted by DarrylBurke View Post
    Shouldn't that be grolsch de drank? ;)
    How should I know? I don't know what Jim is boozing at this ungodly hour ... "jenever, the basic nutricient for every healthy breakfast".

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  16. #16
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,039
    Rep Power
    6

    Default Re: Java Heap Space Error...

    Don't you know? It's not booze. It's that nasty American water. :)

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Java Heap Space Error...

    Eau de Americana?
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  18. #18
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default 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.

    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();
                                    }
     
     
                                }
     
                            }
                        }
                     }
              }
          }
    Any ideas? It seems right...

  19. #19
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Java Heap Space Error...

    Quote Originally Posted by intenseza View Post
    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.

    Java Code:
    for(int i=0; i< DATA.length;i++)
            {
                     
                Sum += DATA[i][0][0][0][0][0].Sum;      // An extra 3 additions
                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;  // An extra 3x2 (6) additions
                        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;  // An extra 3x2x6 (36) additions
                            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;  // An extra 3x2x6x6 (216) additions
                                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;   // An extra 3x2x6x6x4 (864) additions.... 
                                    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();
                                    }
     
     
                                }
     
                            }
                        }
                     }
              }
          }
    Any ideas? It seems right...
    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);

  20. #20
    intenseza is offline Member
    Join Date
    May 2012
    Posts
    11
    Rep Power
    0

    Default Re: Java Heap Space Error...

    Quote Originally Posted by SJF View Post
    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);
    Is this only dealing with a 2d array though? I have a 6d array at the moment?

    Regards

Page 1 of 2 12 LastLast

Similar Threads

  1. Java Heap Space Error
    By wanna learn more :) in forum Advanced Java
    Replies: 3
    Last Post: 03-26-2012, 01:35 PM
  2. Java Heap space error using ArrayList.
    By AcousticBruce in forum New To Java
    Replies: 13
    Last Post: 01-03-2011, 02:06 PM
  3. Replies: 5
    Last Post: 08-13-2010, 11:04 AM
  4. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 10:31 AM
  5. Java heap space error
    By gezzel in forum New To Java
    Replies: 19
    Last Post: 09-25-2008, 01:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •