View Issue Details

IDProjectCategoryView StatusLast Update
0001671NoesisGUIUnity3Dpublic2020-05-07 20:09
ReporterrockhoundAssigned Tosfernandez 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.2.6 
Target Version3.0.0Fixed in Version3.0.0 
Summary0001671: Adding elements to a panel and removing them is not de-allocating memory
DescriptionIf we check ControlGallery's sample project it seems like memory allocated reported by NoesisSettings in Noesis' Unity Package is going up and down based on which elements are being displayed. Seems like a simple Child = null is enough to trigger the unloading of those resources.

On the other hand in the example provided here, ControlGallery sample itself as well as the Inventory sample are being added to a Grid and later removed but reported memory allocated is not going down.
Steps To Reproduce- Download Unity project at: https://we.tl/t-gMO412HYXq
- Open downloaded Unity project and "Reimport" Assets/Resources/GUI folder to make sure xaml files are imported correctly
- Keep an inspector open with NoesisSettings selected
- Press play on scene Assets/Scenes/SampleScene
- On the open scene:
-- Pressing on the first 2 buttons removes all elements added to grid and then loads chosen sample and adds to grid
-- Pressing on the 3rd button simply removes all elements from grid
- Watch allocated memory grow after repeatedly pressing them.
TagsC#, Memory, Unity
PlatformAny

Activities

sfernandez

sfernandez

2020-05-01 15:42

manager   ~0006306

Some of the leaks come from event hooking, there is a known problem we described here: https://www.noesisengine.com/docs/3.0/Gui.Core.EventsTutorial.html#weak-events-in-c
Changing ControlsGallery sample code to use a WeakReference as bridge for event hooking makes that sample to properly release memory (you can verify it if you add a GC.Collect + GC.WaitForPendingFinalizers to your ClearAllScreens function).

For the Inventory sample there are other issues I was not able to identify yet, we'll continue working on that.
sfernandez

sfernandez

2020-05-01 15:43

manager   ~0006307

ControlGallery MainWindow.xaml code behind updated.

MainWindow.xaml.cs (8,312 bytes)
sfernandez

sfernandez

2020-05-05 00:52

manager   ~0006318

After more investigation I found interactivity classes are also producing memory leaks.
We will fix all the problems related to those classes for the next release.
rockhound

rockhound

2020-05-05 18:35

reporter   ~0006321

Last edited: 2020-05-05 18:39

View 2 revisions

Thanks sfernandez. Was about to post reporting that replacing event hooks with WeakReferences didn't show any improvements in our project's memory usage. We are looking forward for your next release.

jsantos

jsantos

2020-05-05 21:23

manager   ~0006322

Already fixed in our repository, will be available tomorrow in RC5

Issue History

Date Modified Username Field Change
2020-04-27 20:01 rockhound New Issue
2020-04-27 20:01 rockhound Tag Attached: C#
2020-04-27 20:01 rockhound Tag Attached: Memory
2020-04-27 20:01 rockhound Tag Attached: Unity
2020-04-27 23:55 rockhound Steps to Reproduce Updated View Revisions
2020-04-28 10:38 sfernandez Assigned To => sfernandez
2020-04-28 10:38 sfernandez Status new => assigned
2020-04-28 10:38 sfernandez Target Version => 3.0.0
2020-04-28 13:39 rockhound Steps to Reproduce Updated View Revisions
2020-05-01 15:42 sfernandez Status assigned => feedback
2020-05-01 15:42 sfernandez Note Added: 0006306
2020-05-01 15:43 sfernandez File Added: MainWindow.xaml.cs
2020-05-01 15:43 sfernandez Note Added: 0006307
2020-05-05 00:52 sfernandez Note Added: 0006318
2020-05-05 18:35 rockhound Note Added: 0006321
2020-05-05 18:35 rockhound Status feedback => assigned
2020-05-05 18:39 rockhound Note Edited: 0006321 View Revisions
2020-05-05 21:23 jsantos Note Added: 0006322
2020-05-07 20:09 sfernandez Status assigned => resolved
2020-05-07 20:09 sfernandez Resolution open => fixed
2020-05-07 20:09 sfernandez Fixed in Version => 3.0.0