Bug #5576
closedmemory leak in ptolemy.data.expr.CachedMethod
0%
Description
There is a memory leak in CachedMethod where the same method is inserted multiple times into the static hash table _cachedMethods. You can see this by running the attached model created by Jianwu. The model has an Expression actor, which uses trim(), isEmpty(), split(), and map(). The model iterates 1000 times, and afterwards jmap reports there are 1004 CachedMethods in the heap:
jmap -histo:live 6959 | grep CachedMethod
38: 1004 40160 ptolemy.data.expr.CachedMethod
Most of these CachedMethods are for map(). The problem is that each CachedMethod for map() has a different hash code. The hash code for a CachedMethod is computed by using the method's argument types and map()'s first argument is a FunctionType. The hash code for FunctionType is based on the hash code for FieldTypeTerm, which is unique for each instance since it does not override Object.hashCode().
Files