WPF viewport3D and LineVisual3D memoryleak problem
Hi there,

Im working now for a while with the excellent libs DXEngine and PowerToys.

Currently Im running into an issue which Im unable to solve and maybe anyone had the problem before. Here is the scenario:

- WPFs viewport3D to display 3D content
- creating ~2000 LineVisual3D added to ContainerUIElement3D
- rendering using Ab3d.Utilities.LinesUpdater.Instance.Refresh() method

in the program the user can switch between diffrent scenes which makes it necessary to unload the 3D content completely and draw a new scene / all visuals. That is done by
- [viewport3d].Children.Remove([ContainerUIElement3D])
- Ab3d.Utilities.LinesUpdater.Instance.Reset();
- generate new 3d-Lines
- add to [ContainerUIElement3D]
- add [ContainerUIElement3D] to [Viewport3D]

In ressource explorer from VS I notice after deleting a scene that several hundred MB are still reserved.
A Hashtable 600MB containing 112k entries (ie. EventManager3D, Linesupdater etc.) and other 3D stuff referencing to LinesUpdater.

How can the 3dLines be disposed, so GC detects unused objects?
I finally solved that issue.

To those who may have a similar problem:

the problem wasn't the Linesvisual3D, but EventSource which didnt Dispose automatically, since the reference in the eventmanager still existed.

The solution was to put all visuals with Events (TextVisual3D, Planevisual3D) into a dedicated collection and when deleting the scene, first remove (foreach) them by "ab3d.Eventmanager.RemoveEvenetsSource3D. The rest is dont by the GC
Are you using the latest version of Ab3d.PowerToys v8.2?

In the previous version it was possible that under some circumstances the 3D lines were not released and could remain in memory. This was hopefully fixed in the latest version.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)