BUG-4556: enable DataSchemaContextTrees to be scavenged 94/29094/2
authorRobert Varga <rovarga@cisco.com>
Sun, 1 Nov 2015 12:09:02 +0000 (13:09 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 2 Nov 2015 08:19:03 +0000 (08:19 +0000)
commit6f14ad09b508858a7752eee74a29e14cad9278b3
treeec98aa73ec72ab68c06ddfaec08e0dc3e610ba4b
parent06d1ebbe905312ebc52dcd007209670f77832f52
BUG-4556: enable DataSchemaContextTrees to be scavenged

DataSchemaContextTree contains an internal weak-keyed cache, which is
used to speed up lookups and share DataSchemaContextNodes.

Unfortunately the cache uses strong references for values (e.g.
DataSchemaContextTree) instances, which transitively (via
DataSchemaContextNode) retain the reference to the key. This has the
effect of the key being always reachable, thus causing a memory leak.

Make the cache use weak references for values, which ensures that it
gets scavenged whenever its contents are no longer referenced.

Change-Id: I1684d1bf2c2c5cdc44cda1e8e508149ff3a8fae4
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/DataSchemaContextTree.java