• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang OutOfMemoryError

 
rupambigai permal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I'm getting java.lang.OutOfMemoryError everytime I select more than 50,000 records from mysql database. There is no problem if the result set is less than 50,000. I've already tried increasing the tomcat heap size to maximum but it didn't solve the problem. I'm actually selecting the records from the database using servlet and placing it in a java bean. How can I solve this problem.

Thank you,
rupa
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Select fewer records in one go. What do you need 50000 at the same time for? Its usually very unlikely that you will be able to display 50000 records on a web page (my assumption, since you mention you are using a servlet), so instead select them smaller chuncks.
 
rupambigai permal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your suggestion. But the problem is I have to select all those records and output it to one text file. How can I do that? Thank you again.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My recommendation doesn't change. If you are sure it is the data retrieval which is causing your OutOfMemoryException (and at 50000 records it probably is) retrieve them in smaller chunks and append them to your file.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic