| Summary: | Allow WeakIdentityMap cleanupSize to be set | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Andreas Nader <naderandi> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | aliaksei.lahachou, tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
Converting to an Enhancement request. We should allow the cleanup size to be something other than the size of the map. We have a similar problem: I'm looking at a dump, which has more than 800000 WeakReferences that reference nothing. WeakReferences, HashEntries, LinkedNodes, and ReferenceCacheKeys alone account for more than 200 MB RAM. And that's for empty cache! One of the biggest SoftCacheWeakIdentityMaps has the cleanupSize=105471 and the cleanupCount=8784. If I understand the code of WeakIdentityMap correctly, I have to put almost 100000 objects to trigger the next cleanup. I believe allowing to set the cleanup size is not really a fix. The problem seems to be that it is unknown whether there are any dead keys in the map, so the whole map is scanned periodically. Instead, it would be better to create references with a ReferenceQueue and avoid scanning the map completely (similar to what java.util.WeakHashMap does). The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 2.2.0.v20110202-r8913 The cleanup code in the WeakIdentityMap sets the cleanupSize to the size of the map. If the map has a lot of elements the cleanupSize may be set very high. In our application the heap may be filled up with a lot of empty CacheKeys that are never removed, because the cleanupSize is not reached any more. We fixed the problem with overriding the code with this method setting a max cleanupsize to 1000: protected void checkCleanup() { super.checkCleanup(); if (cleanupSize>MAXWEAKCLEANUPSIZE) { cleanupSize=MAXWEAKCLEANUPSIZE; } } Reproducible: Didn't try