thanks very much for the advice. Recyling the same statement
significantly reduces the memory problem, and using prepared statements
is *really* speeding up my code.
Daniel John Debrunner wrote:
to demonstrate the problem, i've written some code which approximates
the code i'm using. (attached)
I'm running Java 1.4.2 with the JVM parameter -Xmx64m.
If you run the test() method, the memory used by the JVM rises to
above 150mb until the following exception happens:
Thanks for the test case.
I noticed that you are not using PreparedStatements for the query or the
insert. Using PreparedStatements will make your program much faster, as
the statement does not need to be recompiled every time. This is true
for all JDBC drivers.
PreparedStatement psq = conn.prepareStatement("SELECT id FROM test WHERE
id = ?");
ResultSet rs = psq.executeQuery();
Your code uses a new Statement object to execute every statement, which
can also be avoided since Statement objects are reuseable. Though I
would recommend PreparedStatements.
Also your code never closes the Statement or ResultSet objects it
creates, this may be contributing to the problem.
Applying the above techniques may allow you to progress past this issue,
though it should still be seen as a bug.