Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

directx memory leak in 2015 WPF graphs

Hi! I'm trying to upgrade our app (quite heavy) to MS 2015 (from MS 2013). I see very large memory leak that's related to graphs. It looks like direct3d engines are leaking memory (do you use both d3d 9 and d3d 10?), as well as wpfgfx_v0400. Basically in couple of hours it leaks around 4G of memory.

 

Are you aware of such leaks? Any ideas how to debug this?

 

It's possible that we're doing something wrong (we did few hacks here and there), but we didn't have such issues with MS 2013...

0 Kudos
Message 1 of 3
(4,950 Views)

Sorry to hear that you are seeing a memory leak. We're not specifically aware of any memory leaks related to Direct3D usage, but perhaps you can help track this down.

 

WPF itself uses Direct3D 9 for rendering. The Measurement Studio WPF graph's Auto and Hardware render modes use Direct3D 10 rendering, which interfaces with WPF's Direct3D9 through a shared surface. Direct3D 10 support is handled through managed wrappers around COM types, and video card drivers also have their own unmanaged memory pool that is atributed to the process.

 

Here are a few things to try (in suggested order):

  1. If you are using Graph.RenderMode=Auto (the default), try switching Graph.RenderMode=Hardware instead. Auto cycles between Hardware and Vector based on data size and update frequency; it's possible that cycling is causing issues.
  2. Try Graph.RenderMode=Raster for comparison - that will not use Direct3D 10 at all for rendering, and so the only Direct3D usage will be from the WPF platform itself. If leak is much smaller, it's coming directly or indirectly from our Direct3D graphing.
  3. Try this Stack Overflow solution for ballooning wpfgfx_v0400 memory usage
  4. At a regular interval, try using large object heap compaction (requires .NET 4.5.1 or later). This won't help unmanaged memory, but it will help large object heap fragmentation, which applies to double[] with more than 1,000 values, or any type that is more than 85 KB.
  5. At a regular interval, try removing the graph, plots, and all renderers from the visual tree, then creating a new graph in its place - the removal of the graph from the visual tree triggers disposal of the unmanaged objects associated with the Direct3D10 rendering.
  6. If you create and destory windows, unload the graph from the window first - the removal of the graph from the visual tree triggers disposal of the unmanaged objects associated with the Direct3D10 rendering.

 

I also have a few questions:

  • What kind of graph are you using? (cartesian, polar, intensity, digital, mixed analog/digital)
  • What kind of data are you plotting? (waveform, scatter, etc)
  • What data types are you plotting? (Point[], AnalogWaveform<double>, etc)
  • How are you rendering your data? (lines, points, bars, etc)
  • What kind of graphics card do you have? (Brand, integrated vs stand-alone, mobile vs desktop)
  • What OS are you running on?

 

Message 2 of 3
(4,936 Views)

You need to reset the Content property (of the VisualModel3D) to 'NULL'  because your object is still reference by the geometry, which is hold by a vertex buffer in directx

0 Kudos
Message 3 of 3
(4,170 Views)