ObjectDB ObjectDB

High memory consumption even after close() of EntityManagerFactory

#1

Hello, we still have memory usage problems. When debugging, we have now observed a case in which the execution of multiple queries increasingly byte array were generated (about 1.5 GB) which from GC could not be released. Not even after the EntityManagerFactory closed.

We created a small test with which you can observe similar behavior.
The huge memory usage only occurs if we execute the query (line 56 to 61). If we remove this query, all is well.


The memory is only released after we re-run a query (on a different database).

Do you have an explanation?

edit
delete
#2

The memory is held by ObjectDB in a database page object pool, with the purpose of reducing large object creation. It is unclear if this optimization is still useful in more modern JVM implementations.

Build 2.6.3_06  introduces an option to disable this pool by setting a system property:

    System.setProperty("objectdb.temp.avoid-page-recycle", "true");

This can also be set as a JVM argument:

> java ... -Dobjectdb.temp.avoid-page-recycle=true

In addition, this memory will automatically be released (if the pool is not disabled) on EntityManagerFactory close.

 

ObjectDB Support
edit
delete
#3

The optimization of memory usage was very effective.

  • The test requires now only ~600MB Memory (previously ~1100MB)
  • The not been released memory has been reduced from 400 to 100 MB.

But, the 100 MB byte array are still not released. The option objectdb.temp.avoid-page-recycle makes no change.

The memory can only be released from the GC after the query to the second database connection is performed (line 92).

edit
delete
#4

Addendum:
With the configuration <temp path = "$ temp" threshold = "1mb" /> is the byte array only 3MB.
I think that's OK.

But at threshold = "64mb" the memory is not it released as expected.

edit
delete
#5

Different types of memory buffers are used by ObjectDB:

  • Pool of database pages for reuse - this can be disabled now with objectdb.temp.avoid-page-recycle
  • Other lists, including query results, flush updates, etc. are not affected by the new option, but can be controlled by the temp threshold configuration (per list, not globally).

The pool of database pages is now released (if active) on EntityManagerFactory close. However, there are other structures that should be released too, and this will be addressed in next versions.

ObjectDB Support
edit
delete
#6

You may try build 2.6.3_07 that should improve query resources release.

ObjectDB Support
edit
delete
#7

Thanks, now it works (Or rather, the memory consumption is as expected).

But we observed no effect by the new property 'objectdb.temp.avoid-page-recycle'. Now it works well with and without this property!

edit
delete

Reply

To post on this website please sign in.