emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

Memory leak in rollback #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?
3.0.1

Please describe the problem.  Unit tests are best!
This loop shows a memory leak : 
while (true)
{
  i++;
  if (i % 1000 == 0) { show_memory_used() }
  try
  {
    DAO.openSession();
    DAO.selectXXX();
    DAO.rollbackTransaction();
  }
  finally { DAO.closeSession(); }
}

Please provide any additional information below.

I'm using mysql-connector-java-5.1.12-bin.jar. After the loop as run a while, I 
can see a lot of objects com.mysql.jdbc.Field hanging around.
That's resultset metadata. 

I've not been able to find why these objects are not garbaged, but comparing 
with commit(), I modified my copy of MyBatis. 

In org.apache.ibatis.executor.BaseExecutor, I added in the method rollback a 
flushStatements() after the clearLocalCache().
This solved the leak, but is this modification valid ?

Regards
Luc Vidal

Original issue reported on code.google.com by luc.vi...@laposte.net on 28 Sep 2010 at 2:17

GoogleCodeExporter commented 9 years ago
Which executor are you using?

Original comment by nathan.m...@gmail.com on 2 Nov 2010 at 2:42

GoogleCodeExporter commented 9 years ago

Original comment by nathan.m...@gmail.com on 2 Nov 2010 at 3:44

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 4 Apr 2012 at 10:40