File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes OutOfMemoryError at the time of batch run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "OutOfMemoryError at the time of batch run" Watch "OutOfMemoryError at the time of batch run" New topic

OutOfMemoryError at the time of batch run

akshit indra

Joined: Sep 14, 2011
Posts: 1
I have a batch file which gets transferred by a batch run.Data from batch file are read and then a match is done to insert data into database.
Sample data(from batch file):
..............................................................(96253 lines)
Earlier a class was used to parse first 4 data(ie 12,234,asd,3456)and then a match was made to enter these data into database.
Code has been written in a fashion to read data using stringTokeniser and nextToken().
Now I need to read last data in each line and then I have to do a match through database and proper translation is done and finnaly I have to enter translated data for it.(awer=>translatedkey;and then translatedkey into Databaase)
I used the same coding pattern and read last data (token by token using nextToken()) and it has worked fine in test environment which has only 300 lines.but problem arises when the same batch(class run in production which has big file 96253 lines)
The issue :
Exception in thread "main" java.lang.OutOfMemoryError:
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Please help me to find the issue and solution too.

NOTE:I thought since data are read token by token; that might have causes the issue. so I tried to read direct last data of each line using
String result =s.substring(s.lastIndexOf(',')+1, s.length());//but it did not work as the other codes have been written in
a manner to give data token by token. so instead of getting awer I get asv

can I use

s.nexttoken();s.nexttoken(); and s.nexttoken(); to read last column

I agree. Here's the link:
subject: OutOfMemoryError at the time of batch run
It's not a secret anymore!