File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.OutOfMemoryError" Watch "Exception in thread "main" java.lang.OutOfMemoryError" New topic

Exception in thread "main" java.lang.OutOfMemoryError

sarathchandra chandala

Joined: Sep 06, 2007
Posts: 9

I have to insert around 80 lacs of rows in to the table,while inserting suddenly i got this exception ----->Exception in thread "main" java.lang.OutOfMemoryError<--------

i increased the heap size to 1024m, but same problem is coming

is there any alternative to solve this problem or any other solutions
Ricky Martaputra
Ranch Hand

Joined: Apr 04, 2005
Posts: 42
Maybe you should fixed/recheck your algorithm.

For example:
If you want to insert 80 lacs ( I do not get what lacs is ), used some buffer strategy. In case, put you 10 lacs in a List, save, then clear the list ( list.clear() ) to put next 10 lacs. Do it repeatedly until 80 lacs.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45307
I would expect 80 crore to overwhelm your memory, but not 80 lakh.
Have you got some sort of recursion which doesn't terminate?
[ April 25, 2008: Message edited by: Campbell Ritchie ]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45307
Actually, how long is each line?
80 lakh * 100 Bytes is about 800MB so even 80 lakh might overwhelm your resources.
What sort of table are you inserting into? A database? Are you using anything which maintains the lines in memory after you have inserted them? If you are inserting into a database, is there any delay in the database? Can you put a tiny delay between successive lines? Can you split the process so as to insert 1 line at a time?

And lakh (also spelt lac) = 100000
I agree. Here's the link:
subject: Exception in thread "main" java.lang.OutOfMemoryError
It's not a secret anymore!