usethesource/vallang

TypeFactory should keep types in a weak reference, as it currently leaks

DavyLandman opened this issue · 1 comments

After running rascal quite a while, and running multiple programs, the TypeFactory gets quite big, in a recent session 1 GB of memory was kept around by the TypeFactory . Analyzing the heapdump showed that the signatures of all the functions, and all their previous versions were in there as tuple-types, similarly for ADT's that had slowly evolved.

I understand why the TypeFactory exists, it makes type equality a reference check. And we should keep this. But if we store the types as a WeakReference, than they'll disappear from the factory cache, as soon as nobody references that type anymore.

The TypeStore might be a different story, as we often register stuff in a store, and only later use it.

Good plan. If that idea can safely satisfy the constraint that never two equal types are in memory at the same time; I'd guess there is no issue there