• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryError

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting for bellow code. Total number of rows result set return 300000. This code works fine with embedded SQL. I just replaced embedded query with stored procedure. I am not sure why I am getting this error. Can anyone please help me?

 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're going to need to perform some analysis on your application to find out what you have a lot of on the heap. I'd recommend configuring your JVM to produce a heap dump on OutOfMemoryError, then using something like VisualVM to analyse it.
 
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, do you really need to read alla those rows (300000) ? Can't you introduce any pagination?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That bit of code tells us very little, especially since you do nothing with the row there.

I'll echo the "analyse a heap dump" as well as "do you really need all 300k rows".

I'll add a, what does the actual code look like (execution of the Statement through to the return of the data) for both this version and the original version that apparently handles all 300k rows.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Check for JVM setting .You may need big heap size.
2. More code would help..although try below option........

Take DataSet out from while loop .. why do you need to create 300K objects of dataset ?

do it like this instead.

int cnt=0;
DataSet row = null;
while (rs.next()) {
row = new DataSet(columns);
for (int i = 1; i <= numcols; i++) {
row.add(rs.getObject(i));
}
}

Hope this help.

-Subodh
 
reply
    Bookmark Topic Watch Topic
  • New Topic