I work in ActiveMQ Artemis, and we have a series of tests that will
use derby memory, with the uri as
"jdbc:derby:memory:testName;create=true"

So, every test will have its own database, and we do that for
isolating the tests.


at the end of the test, we call destroy and shutdown of derby with:

   try {
      DriverManager.getConnection("jdbc:derby:memory:test;destroy=true");
   } catch (Exception ignored) {
      // it always throws an exception on shutdown
   }


try {
   
DriverManager.getConnection("jdbc:derby:;destroy=true;shutdown=true;destroy=true");
} catch (Exception e) {



So, no matter how hard I try, there is always a memory leak from
DataStore being held at a HashMap, from VFMemoryStorageFactory:tables
I presume. Or there is a "leaked" list (a reference of a reference
somewhere).




I recently developed a framework / library to test and find for memory
leaks, and I have this reproduced here:

https://github.com/clebertsuconic/check-leak/blob/derby-test/examples/junit-example/src/test/java/io/github/checkleak/junitexample/DerbyLeakTest.java



So, either I'm supposed to do something else in order to Derby to
remove the hashmap, or there's an actual leak.


So, I need to either identify what I'm doing wrong...


or if this is an actual issue, I need help to build derby and debug
the issue further.


I tried building with:

ant buildjars
mvn -f maven2/pom.xml install

( I need to consume derby in Maven, so I can test it in my process).





I wasn't sure this would be appropriate for the user's list as it
might be an actual bug that I need help with how to develop a fix.






*******************************************************************************************************************************
References to obj[4]=TOSTRING(org.apache.derby.impl.io.vfmem.DataStore@4dbad37),
class=org.apache.derby.impl.io.vfmem.DataStore
!-- FieldReference name='value'::=java.lang.Object
java.util.HashMap$Node.value on object
TOSTRING(/Users/clebertsuconic/work/apache/check-leak/examples/junit-example/test4=org.apache.derby.impl.io.vfmem.DataStore@4dbad37),
class=java.util.HashMap$Node
!--!-- arrayRef [Ljava.util.HashMap$Node;[5] id=@1883788127
!--!--!-- FieldReference name='table'::=transient
java.util.HashMap$Node[] java.util.HashMap.table on object
OBJ(java.util.HashMap@1492156162)
!--!--!--!-- StaticFieldReference public static final int
org.apache.derby.io.StorageFactory.VERSION_NUMBER
!-- arrayRef [Ljava.lang.Object;[4] id=@987950392
!--!-- Reference inside a method -
io.github.checkleak.core.CheckLeak::exploreObjectReferences
!--!-- Reference inside a method -
io.github.checkleak.core.CheckLeak::exploreObjectReferences

--
Clebert Suconic

Reply via email to