Nightmare java leak… with loop and jdbc

前端 未结 4 1899
臣服心动
臣服心动 2021-01-23 06:25

When I run the following code in the profiler, I get a char[] and byte[] that build up until the program crashes due to a java heap out of memory exception. Can someone tell me

4条回答
  •  遇见更好的自我
    2021-01-23 06:50

    I would change this:

                            statement.executeQuery(rawQuery);
                            results = statement.getResultSet();
    

    to this:

                            results = statement.executeQuery(rawQuery);
    

    The latter is certainly the API-approved way to do this, and while I can't say for certain that the former is a problem, it certainly seems like it could create two separate result-sets, of which you only close one.

提交回复
热议问题