Hi,
we noticed a severe issue of memory leak using a binded UltraWinTree; our tree is binded to a collection of classes: we fill in and empty this collection but when this collection is empty, classes previously showed in the tree (and then disposed) remain alive. It seems that the tree element stores a pointer to the classes inside an internal field named nodeClientAreaUIElement
Note : we don't have to dispose the tree until the program is closed because its possible to refill the collection more times.
In attach a little sample reproducing our issue.
Is there a solution to avoid this issue? Will it be fixed in the future releases ?
(issue found on release 11.1)
Best regards
mauro_sturaro said: Hi, we noticed a severe issue of memory leak using a binded UltraWinTree; our tree is binded to a collection of classes: we fill in and empty this collection but when this collection is empty, classes previously showed in the tree (and then disposed) remain alive. It seems that the tree element stores a pointer to the classes inside an internal field named nodeClientAreaUIElement Note : we don't have to dispose the tree until the program is closed because its possible to refill the collection more times. In attach a little sample reproducing our issue. Is there a solution to avoid this issue? Will it be fixed in the future releases ? (issue found on release 11.1) Best regards
Tomorrow I'll check to make sure this bug was entered into the system so it gets fixed and enter it if necessary. As a possible work around until the release that fixes the bug, you could do something as below to kill off the memory reference for garbage collection.
private void btClear_Click(object sender, EventArgs e) { ultraTree1.SelectedNodes.Clear(); _Source.Clear(); if (ultraTree1.UIElement != null) { if (ultraTree1.UIElement.ChildElements.Count > 0) { if (ultraTree1.UIElement.ChildElements[0] is Infragistics.Win.UltraWinTree.NodeClientAreaUIElement) { ultraTree1.UIElement.ChildElements[0].Dispose(); ultraTree1.UIElement.ChildElements.Add(new Infragistics.Win.UltraWinTree.NodeClientAreaUIElement(ultraTree1.UIElement)); } } } }
Ok, Thanks a lot !
I'll check the next releases
meanwhile, the work around is working fine ;-)
Hello ,
I have created a support ticket for you with id CAS-68065-QP80NT and I will link this case to the issue in our system, in order to notify you when the fix is available for you.
Thank you.
Hello, I have to give you some updates about issues on UltraTree: after we put the workaroud suggested we found a couple of other points where the tree keeps a pointer to the source object:- pivotItem: it's an internal field containing the pointer: to empty this field we found an interface method ISelectionManager.SetPivotItem() to set this pointer to null but also this it's another work around.- lastHoverNode: it's another internal field set only when a Drag&Drop happens and never reset!! Also this field mantains a pointer to our class causing memory leak.Is there a way to reset it ?Thanks in advance Mauro
The original memory leak in this post should be fixed in the next service release.
These two new fields you came across have been entered into the system for engineers to take a look at. If I get a free moment in the near future I'll see if I can create a work around until the next service release.
Hi Guys,
bad news, the Memory Leaks is worse. Now to realease properly I have to run this code :
internal void ReleaseTree() {
try {
SelectedNodes.Clear();
ResetActiveNode();
ResetDataSource();
TopNode = null;
if (UIElement == null)
return;
var uIElement = UIElement;
if (uIElement.ChildElements.Count <= 0)
var clientArea = uIElement.ChildElements[0] as NodeClientAreaUIElement;
if (clientArea == null)
clientArea.Dispose();
uIElement.ChildElements.Add(new NodeClientAreaUIElement(uIElement));
var cuie = ControlUIElement;
if (ControlUIElement == null)
var pinfo = cuie.GetType().GetProperty("LastElementWithFocus", BindingFlags.Instance | BindingFlags.NonPublic);
if (pinfo == null)
var element = pinfo.GetValue(cuie, null) as Infragistics.Win.UIElement;
if (element != null) {
element.Dispose();
pinfo.SetValue(cuie, null, null);
}
var pinfo1 = cuie.GetType().GetProperty("NodeClientAreaUIElement", BindingFlags.Instance | BindingFlags.NonPublic);
if (pinfo1 == null)
var element1 = pinfo1.GetValue(cuie, null) as NodeClientAreaUIElement;
if (element1 == null)
var pinfo2 = element1.GetType().GetField("nodeElements", BindingFlags.Instance | BindingFlags.NonPublic);
if (pinfo2 == null)
var dict = pinfo2.GetValue(element1) as System.Collections.Generic.Dictionary<UltraTreeNode, TreeNodeUIElement>;
if (dict != null)
dict.Clear();
} catch (Exception exc) {
if (ExceptionHelper.IsAsynchronousException(exc))
throw;