-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Null the value field when the entry is dead (evicted)
In #103 a user broke the map contract by accidentially modifying the key, causing lookups to not find the entry. This includes eviction, which finds the entry on a linked list ("Node") and removes from the hash table with the stashed key. While the node can be marked as dead, the removal might fail in practice if racing with an explicit invalidation. When an weak/soft value entry is dead we already clear the reference to reduce the GC burden. In the common case null'ing out the field would have no benefit, because the GC would trace live objects and not need the hint. In the above case it reduces the impact of a memory leak by collecting the heavy user objects. The node instances would still accumulate and the leak may take longer to fail. But since we do it for reference caching and it could reduce the likelihood of outages, it does seems friendlier to null the strong value field.
- Loading branch information
Showing
5 changed files
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters