This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError: Java heap space

 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have wriiten a query which will fetch records more than 2 lakhs.
and i have written the code as
PreparedStatement pstmt = connection.prepareStatement("select * from BIG_TABLE where col1=?");
pstmt.set....
pstmt.executeQuery();

When i execute this code am getting
java.lang.OutOfMemoryError: Java heap space
I get this exception when the code executes executeQuery().

Can anyone provide me a solution ?
Thanks in advance
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Out of memory simply means the memory consumption by the application exceeds the total memory available for JVM.

The problem can occur if your code is sloppy. Precisely if you have a memory leak. So the buzzword is optimize and stabilize your code.

Other than that it says that your Java application needs a lot of memory (more than 128 MB of default). In this case the Java heap size can be increased using the runtime parameters:

java -Xms<initial heap size> -Xmx<maximum heap size>

The default values are java -Xms32m -Xmx128m

Also, you may refer this post with similar issues.

Hope that helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic