I am using an in memory h2 database with the following configuration:
jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1
hibernate.dialect=org.hibernate.dialect.H2Dialect
jdbc.user=sa
jdbc.pass=
I can see that the used memory on the system keeps on decreasing. And as soon as I restart the application, the memory comes back. I got the memory dump but it does not show any running threads that are occupying lot of memory. I am guessing this is because of the h2 database.
I checked the jmap result and it shows the following:
BEFORE:
I tried to use h2 shutdown and manually call the System.gc(). That helps the jmap as shown below:
AFTER:
However, the freed memory never reaches the OS/system. Neither the used memory goes down NOR the free memory increases !!
What am I missing here ? If the memory keeps increasing, my machine will always keep crashing after running for few days ? Cannot keep restarting every 2 days !