Profile Picture

NDrawingViewControl Memory Leak

Posted By Jan Cruz Last Year
Author
Message
Jan Cruz
Problem Posted Last Year
View Quick Profile
Junior Member

Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 10, Visits: 346
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.



Nevron Support
Posted Last Year
View Quick Profile
Supreme Being

Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)

Group: Forum Members
Last Active: 2 days ago @ 4:12 AM
Posts: 3,055, Visits: 4,042
Hi Jan,

Thank you for the detailed description of the issue and the screenshots. It would be great if you send us a sample project that demonstrates the issue. We will then be able to debug it and tell you what's wrong and how to fix it. You can add a ZIP archive with your project to a new comment in this forum topic or upload it to a cloud service of your choice and send a download link in a new comment.

Thank you!


Best Regards,
Nevron Support Team



Jan Cruz
Posted Last Year
View Quick Profile
Junior Member

Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)Junior Member (23 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 10, Visits: 346
Hi,

Thank you for the response.
I have attached the demo code.

Thanks.

Attachments
Nevron Support
Posted 2 Weeks Ago
View Quick Profile
Supreme Being

Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)Supreme Being (4,437 reputation)

Group: Forum Members
Last Active: 2 days ago @ 4:12 AM
Posts: 3,055, Visits: 4,042
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





Similar Topics


Reading This Topic