Re: Memory Leak in PropertyCache: need ideas

2008-08-23 Thread Andreas Delmelle
On Aug 23, 2008, at 00:59, Peter B. West wrote: Jeremias Maerki wrote: There's a lot of AND-ing of hash codes to determine the segments and buckets and that's much easier to handle if you have a power of 2 and can shift bits around. On 22.08.2008 16:22:05 Peter B. West wrote: Jeremias Maerki

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Jeremias Maerki
Thanks for looking into it, Andreas! On 22.08.2008 00:15:00 Andreas Delmelle wrote: snip/ So, I was wondering about the role of the reference queue. Calling poll() returns the first reference /if/ one is available, so it seems likely that cleanSegment() does get called frequently enough,

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Jeremias Maerki
I think I got it now. I'll clean up the code now, do multi-threading tests now and then prepare a patch for review. Just a question in the meantime: What's the purpose of the hash(Object) function in PropertyCache? It seems to just hash a hash code. At any rate, when I made sure that I always

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Jeremias Maerki
Ok, here's the final patch I'd propose to fix the memory leak. I've seen no measurable performance degradation compared to the base revision and no multi-threading problems. The memory leak is fixed and the number of stale references remains low. Feedback welcome. On 22.08.2008 12:06:56 Jeremias

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Peter B. West
Jeremias Maerki wrote: Ok, here's the final patch I'd propose to fix the memory leak. I've seen no measurable performance degradation compared to the base revision and no multi-threading problems. The memory leak is fixed and the number of stale references remains low. Feedback welcome. What

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Jeremias Maerki
There's a lot of AND-ing of hash codes to determine the segments and buckets and that's much easier to handle if you have a power of 2 and can shift bits around. On 22.08.2008 16:22:05 Peter B. West wrote: Jeremias Maerki wrote: Ok, here's the final patch I'd propose to fix the memory leak.

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Andreas Delmelle
On Aug 22, 2008, at 12:06, Jeremias Maerki wrote: I think I got it now. I'll clean up the code now, do multi-threading tests now and then prepare a patch for review. Just a question in the meantime: What's the purpose of the hash (Object) function in PropertyCache? It seems to just hash a

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Andreas Delmelle
On Aug 22, 2008, at 16:29, Jeremias Maerki wrote: [Peter: ] What happens is SEGMENT_COUNT is not a power of 2? Or, what obliges SEGMENT_COUNT to be a power of 2? There's a lot of AND-ing of hash codes to determine the segments and buckets and that's much easier to handle if you have a power

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Andreas Delmelle
On Aug 22, 2008, at 15:01, Jeremias Maerki wrote: Ok, here's the final patch I'd propose to fix the memory leak. I've seen no measurable performance degradation compared to the base revision and no multi-threading problems. The memory leak is fixed and the number of stale references

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Andreas Delmelle
On Aug 22, 2008, at 10:34, Jeremias Maerki wrote: On 22.08.2008 00:15:00 Andreas Delmelle wrote: snip/ So, I was wondering about the role of the reference queue. Calling poll() returns the first reference /if/ one is available, so it seems likely that cleanSegment() does get called frequently

Re: Memory Leak in PropertyCache: need ideas

2008-08-22 Thread Peter B. West
Jeremias Maerki wrote: There's a lot of AND-ing of hash codes to determine the segments and buckets and that's much easier to handle if you have a power of 2 and can shift bits around. On 22.08.2008 16:22:05 Peter B. West wrote: Jeremias Maerki wrote: Ok, here's the final patch I'd propose to

Memory Leak in PropertyCache: need ideas

2008-08-21 Thread Jeremias Maerki
I've been made aware of a slow memory leak. I was able to identify PropertyCache as the leaker. It appears as if the cache segments don't get cleaned correctly. The majority of CacheEntry instances have a cleared reference but don't get removed from the buckets. In time that accumulates to

Re: Memory Leak in PropertyCache: need ideas

2008-08-21 Thread Andreas Delmelle
On Aug 21, 2008, at 18:20, Jeremias Maerki wrote: Hi Jeremias I've been made aware of a slow memory leak. I was able to identify PropertyCache as the leaker. It appears as if the cache segments don't get cleaned correctly. The majority of CacheEntry instances have a cleared reference but don't

Re: Memory Leak in PropertyCache: need ideas

2008-08-21 Thread Jeremias Maerki
I've tested only on Windows with Sun JDK 6.0_03 (dual core, non-multithreaded in MemoryEater). The reporter will have had a different setup but I don't know what it is without asking back. I believe it's JVM-independent. cleanSegment() does get called but I suspect it doesn't get called regularly

Re: Memory Leak in PropertyCache: need ideas

2008-08-21 Thread Andreas Delmelle
On Aug 21, 2008, at 18:47, Jeremias Maerki wrote: I've tested only on Windows with Sun JDK 6.0_03 (dual core, non-multithreaded in MemoryEater). The reporter will have had a different setup but I don't know what it is without asking back. I believe it's JVM-independent. cleanSegment() does get