Does anyone know if it is expected in derby to accumulate memory in
a single transaction if you don't close statements or resultSets?
I am pretty sure not closing ResultSets is a problem, I am not sure
about Statements.
Daniel John Debrunner wrote:
> Chris wrote:
>
>
>>Hi,
>>
>>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.
>
> See
>
> http://incubator.apache.org/derby/manuals/tuning/perf21.html#HDRSII-PERF-18705
>
> E.g.
>
> PreparedStatement psq = conn.prepareStatement("SELECT id FROM test WHERE
> id = ?");
> psq.setInt(1, 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.
>
> Dan.
>
>
>
>
>
|