NDrawingViewControl Memory Leak


Author
Message
RLDP 2000
RLDP 2000
Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)Forum Member (28 reputation)
Group: Forum Members
Posts: 11, Visits: 387
Hi Nevron Support,

I would like to report a problem with a possible memory leak encountered when using NDrawingViewControl in WPF application.
Here is my setup:

Sample Application:

This is a simple WPF Application (.NET Framework 4.7.2, using NOV version 24.6.3.12).

When I open then close the PageDialog, my memory consumption does not decrease.
I am also forcing the call to the garbage collector on PageDialog.Closed event.


Here is my CustomCanvas class


I also checked memory leaks using JetBrain's dotMemory profiler to confirm if memory leak occurs.

I hope I was able to explain well the details of this possible issue.

If you want to check my full demo app, please provide details on how I can share my source code with you.


I hope you have already a solution for this issue.
I would appreciate it if you can share the solution with me.

Thanks.


Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Jan,

Thank you for the sample project. We analyzed it and found the issue. Because you are not using native Nevron windows (NTopLevelWindow instances), you should clear them manually from the Nevron Open Vision (NOV) Desktop's Windows collection. Please update the code of the PageDialog's PageDialog_Closed event handler to:


private void PageDialog_Closed(object sender, EventArgs e)
{
  canvas.ActivePage.Items.Clear();
  // Remove the display window of the canvas from the Windows collection of the NOV Desktop object
  NApplication.Desktop.Windows.Remove(canvas.DisplayWindow);
  canvas = null;
  Closed -= PageDialog_Closed;
  //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
  GC.Collect();
  GC.WaitForPendingFinalizers();
}


If you decide to use the NOV windows (NTopLevelWindow instances) for the windows and the dialogs of your application, it won't be necessary to manually remove the window from the NOV desktop's Windows collection. For more information on top-level windows, please see the following article:
NOV Top Level Windows

You can also disable the hardware acceleration (GPU rendering) and the paint cache to further reduce memory usage. Please note that that the paint cache can use a specific amount of memory up to a given limit to cache some paint information an textures in order to speed up the rendering. Add the following code in the beginning of the entry point of your application - the "App.OnStartup" method override:


NApplication.EnableGPURendering = false;
NApplication.PaintCacheSettings.Enabled = false;



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search