views:

56

answers:

1

I use SQLite in a java program. While the java program runs, several queries are sent to the database as well as temporary tables are created in memory and then deleted (using DROP).

The problem is that while the number of various operations in the database increases, the memory usage from the java program also increases. As a result, the program crashes at some point with an outofmemory exception. I use PRAGMA temp_store = 2 to keep the temporary table in memory, but I deleted (using DROP tablename) every time before building another one.

Does this have to do anything with the journal the database keeps? How can I solve this problem?

+3  A: 

With out looking at your program it's impossible to say what the problem is. Are you keeping results of queries you run against the database in memory? If your program is written in such a way that you have multiple large JDBC result sets and the garbage collector can't determine weather it's safe to free the memory they use you could easily run out of memory.

Jared
yes, I'm keeping result sets in memory to process it but I assumed that the garbage collector would gather it at some point.. I have used Runtime.getRuntime().gc() but there was no difference. How can I get rid of the result sets explicitly?
zhna
resultSet=null;
Jared
Thanks a lot! Now everything works fine :)
zhna