java.lang.OutOfMemoryError

I have a Query Builder page in which the user can create queries to our local database and view results. I have a general data access class which store the results from a query in an 2d array. When I try to grab everything (select * ..) from a table, I get an OutOfMemoryError. The table has roughly 6200 rows and 34 columns. I assume this if because I am using arrays? What would be the best implementation process?

If I used a Vector, each object stored in the Vector would have to be a row, thus would have the be an array to each columns value. Would this prevent the OutOf Memory Error and be proper practice?

Thank you!

[645 byte] By [vinays84a] at [2007-11-27 5:48:45]
# 1
Actually an List would increase the amount of space required. Avoid slurping up the whole table at one go, or if you must, you'll probably need to increase the memory limit with something like -Xmx256m added to the java command (before the -jar or class name).
malcolmmca at 2007-7-12 15:34:31 > top of Java-index,Java Essentials,Java Programming...
# 2

I actually already have increased the memory to 256mb. The numbers definitely don't add up as for the memory error. I just assumed it was the fact that I was using arrays that caused excess memory allocation for some java reason. How do other java applications usually handle dealing with large amounts of data?

Thank you!

vinays84a at 2007-7-12 15:34:31 > top of Java-index,Java Essentials,Java Programming...
# 3
6200 x 34 doesn't sound like a lot of elements. Are individual elements big? Megabyte-long strings?
Hippolytea at 2007-7-12 15:34:32 > top of Java-index,Java Essentials,Java Programming...
# 4
Could be blobs, it could also be something stupid like not incrementing the result set always adding the same one to the db, a bit hard to tell without getting a look at some code.
Aknibbsa at 2007-7-12 15:34:32 > top of Java-index,Java Essentials,Java Programming...
# 5
I grabbed all the data at once in the Result Set, setting the fetch size of the statement object to 7000. I did this so I could know the row count to initialize the array length. Thus, there was no incrementation and only one added.
vinays84a at 2007-7-12 15:34:32 > top of Java-index,Java Essentials,Java Programming...
# 6
code shows what it is doing not what you think it is doing.
Aknibbsa at 2007-7-12 15:34:32 > top of Java-index,Java Essentials,Java Programming...
# 7
Why jump through any additional hoops to use an array, when it is so easy to use a collection like a List?Not that using a list will make much of a memory footprint difference, I'm just saying...
Hippolytea at 2007-7-12 15:34:32 > top of Java-index,Java Essentials,Java Programming...