Nightmare java leak… with loop and jdbc

前端 未结 4 1861
臣服心动
臣服心动 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 07:01

    I would suggest you try two things:

    Extend your timer to about 10 seconds. Two is expecting a lot for a slow system.

    Put a Thread.currentThread.sleep(10) (or similar) in your idle loop.

    I expect you are not waiting for go to complete. While you are spinning on air in your idle loop the database connecion is dying from lack of cycles and every two seconds you add yet another connection and query. No wonder the poor thing is struggling.

提交回复
热议问题