File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "memory" Watch "memory" New topic
Author

memory

vijayapriya thirumurugan
Greenhorn

Joined: Apr 03, 2009
Posts: 16

hello sir,


Object[][] el=new Object[100][100];
It is working. but i need Object[][] el=new Object[100000][100000];

you sent if i declare

int n=100000;
Object[][] el=new Object[n][n];
it'll work. but it doesn't work.

the error: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
can i store 100000 of values.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

If you do a search you'll find several posts that explain how to assign more memory to the JVM. How much you'll need I can't tell you though, you'll have to play around a bit with different values.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
You are not storing 100000 values in the second example, but 10000000000. You will require a heap space of several tens of GB to fit it in. Most PCs don't have that amount of memory available at all.
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
What are you doing exactly that you would need to do something like that? or are you just testing the JVM limits?

There are more than likely several different work-arounds to doing something like that. Do you really need 10 billion objects in memory all at the same time? Couldn't you read/write/execute/whatever your objects a few at a time? If this is a real problem that you need help with than please give us more details to assist you with. Increasing your system memory is not a good solution in my opinion because I can't think of a single situation in which you would have to have 10 billion objects in memory at one time.

SCJA
~Currently preparing for SCJP6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
If you need 10000000000 (= 100 crore) objects, you would do better to put them into a database. That will happily hold that many objects, assuming you have enough hard drive space.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


10000000000 (= 100 crore)


that sounds more Indian
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
Balu Sadhasivam wrote:that sounds more Indian
Very definitely English . . . but I try to speak your language
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
Campbell Ritchie wrote:1000,00,00,000 (= 100 crore) objects



More like 1000 crore. But full marks for the effort
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
I did say "try". I'm glad I didn't say "Succeed"
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Ok.... what's a crore? Let the rest of us in
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
I thought it was 10^8 (100,000,000) but it is actually 10^7 (10,000,000).
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
So it's an Indian word that represents 10 million? Why would you need such a measurement? The largest measurement I can think of for money that isn't a real number would be a grand or $1,000 :P

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
Maybe it's the number of Java programmers in Bangalore?

But let's get this thread back on topic
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: memory