Fix memory leak in BA mount service 91/81891/5
authorMaros Marsalek <mmarsalek@frinx.io>
Fri, 3 May 2019 12:04:56 +0000 (14:04 +0200)
committerRobert Varga <nite@hq.sk>
Sun, 5 May 2019 17:34:20 +0000 (17:34 +0000)
commit225e9ce237996d321f420291ff6ba59c48a70d9f
treea7b581b488fd2144eaec41f4a513168aa9569036
parentbb366ba1be306e7678d81a116c1415876fa9fc75
Fix memory leak in BA mount service

The cache used in BA mount service uses weakKeys() so the keys (DOM mountpoint)
could be GCed when no ono, except cache, referenced them).
However the values in the cache (BA mountpoint) also kept a reference to
the key, so the key was never weakly reachable and thus never GCed
resulting in a memory leak.

Which is especially visible in case of frequent reconnects of netconf
mountpoints where after every reconnect a new DOM mountpoint is created,
requiring a new BA mountpoint creating new entry in the cache of BA mount service...

Added also a simple test verifying proper cache cleanup

Change-Id: I9c109dd6d499d6185842d6a1ad5a59d75565af5c
Signed-off-by: Maros Marsalek <mmarsalek@frinx.io>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java [new file with mode: 0644]