GeeCON Prague 2014*
The moose likes Java in General and the fly likes travel agent - outofmemory heap error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "travel agent - outofmemory heap error " Watch "travel agent - outofmemory heap error " New topic
Author

travel agent - outofmemory heap error

Abhradeep Banerjee
Ranch Hand

Joined: Dec 09, 2009
Posts: 71
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.substring(String.java:1939)
at java.util.StringTokenizer.nextToken(StringTokenizer.java:335)
at lab6Ex1.main(lab6Ex1.java:81)
Java Result: 1



lab6Ex1




Travel.java



data in Travel_Records.txt:

0|S8470017G|Abhradeep Banerjee | Singapore |09/07/2007 | 13:28 | Kolkata, India | 09/01/2010 | 16:28
1|S22209619B|Debabrata Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore| 09/01/2010 | 16:28
2|S8328944B|Debabrata Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore | 09/01/2010 | 16:28
3|S8470017G|Abhradeep Banerjee | Singapore |09/07/2007 | 13:28 | Kolkata, India | 09/07/2007 | 16:28
4|S8470017G|Abhradeep Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore| 09/08/2007 | 16:28






Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
When I ran it, I did not get an out of memory error. I got an infinite loop.
I moved the br.readLine() to the while loop because you were not reading the next line in the loop.
Fixing this caused an error at the Integet.parseInt() method but that is another issue...
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
I figured out the Integer.parseInt() problem. When I created the Travel_Records.txt file, I added a superfluous carriage return at the end of the file. Now the application prompts me with a list of commands but I do not know what to enter to reproduce the problem.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
When I ran it, I did not get an out of memory error. I got an infinite loop.
Actually, had I been patient enough, I would have gotten the out of memory error but I recognized the problem before that happened.
Abhradeep Banerjee
Ranch Hand

Joined: Dec 09, 2009
Posts: 71
thanks a lot man I got it working
for some reason when i run it on command prompt i get a file Text_Record.txt was not found but i dont get that error when i run it in netbeans
any reason why?

thanks
Alpesh Padra
Ranch Hand

Joined: Jan 10, 2010
Posts: 41
Probably, In Netbeans it will start looking from current directory and get it.

In either case , you need set context path explicitly while using console.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39079
    
  23
Don't use such long lines in code. They make the whole thread very difficult to read.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: travel agent - outofmemory heap error