aardvark-platform / aardvark.rendering

Aardvark.Rendering is a high-performance, dependency-aware rendering engine. It is part of the open-source Aardvark Platform for visual computing, real-time graphics, and visualization.
https://aardvarkians.com/
Other
131 stars 13 forks source link

Memory leaks due to "Hooks" of ModelView* trafos #49

Closed luithefirst closed 5 years ago

luithefirst commented 5 years ago

Please see "06 - MemoryLeakTest" for demonstration.

Using "ModelView*" transformations in shaders will use hooked view and proj transformations combined with the model transform. This will cause the model transform, its computation and source to leak indefinitely.

luithefirst commented 5 years ago

Disabling hooks by shorting "hook" to return "m" in RenderTask.fs Line 555 does not resolve the issue.

leak

The Map2Mod of model and view should no longer be alive, but it is:

leak2

luithefirst commented 5 years ago

preliminary findings: BinaryCache does not work as intended (not fully understood ConditionalWeakTable limitation)

luithefirst commented 5 years ago

The issue with BinaryCache occurs because the derived attributes also hold a reference to their inputs (Map2Mod). This means the BinaryCache keys are also referenced by the cache entry and this keeps both inputs alive as long as one lives. See tests added in Aardvark.Base: 15be1be5 The issue is resolved by introducing Map2ModWeak that does not hold a strong reference to the input and using that for derived attribute computations: 39a811d5, 1754e947

luithefirst commented 5 years ago

Inputs of "weak" mapped mods get collected -> see "09 - TextTrafoTest"

luithefirst commented 5 years ago

Resolved by fix of BinaryCache in Aardvark.Base 4.5.15