Jump to content
Software FX Community

Chart.Export memory usage


AnthonyJones

Recommended Posts

Our application seems to suffer from a memory leak when using the Chart.Export function.  I can replicate the problem with the following code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using System.IO;

using ChartFX.WPF;

namespace WpfApplication1

{

  /// <summary>

  /// Interaction logic for Window1.xaml

  /// </summary>

  public partial class Window1 : Window

  {

  public Window1()

  {

  InitializeComponent();

  btnTest.Click += new RoutedEventHandler(btnTest_Click);

  }

  void btnTest_Click(object sender, RoutedEventArgs e)

  {

  for (int i = 0; i < 25; i++)

  {

  Chart oTestChart = new Chart();

  MemoryStream ms = new MemoryStream();

  oTestChart.Export(FileFormat.Png, ms);

  ms.Close();

  oTestChart = null;

  }

  GC.Collect();

  }

  }

}

In this case, each time the button is clicked, the application's memory usage increases significantly and never seems to reduce again.  The line "oTestChart.Export(FileFormat.Png, ms);" seems to be the culprit - if I remove it the memory usage doesn't increase.

Is there any way of reclaiming the memory once the Export function has been used?  We are using ChartFX.WPF.dll version 8.0.3439.25180.

Thanks in advance!

Link to comment
Share on other sites

I've since noticed that the problem occurs when using FileFormat.Bitmap, FileFormat.Jpeg and FileFormat.Png but not when using FileFormat.Xml or FileFormat.XmlTemplate.  It occurs regardless of whether the image output is to a memory stream or a file.

Has anyone noticed this?  Is there a fix for it?

Link to comment
Share on other sites

  • 2 weeks later...

We did found a leak and it only occurred when you exported a chart that was never rendered "normally" on the screen.

You will need to download any build marked 3476 or later, additionally you will also have to manually invoke a Chart method call UnloadVisuals.

I apologize for the delay, I thought I had posted a comment to this thread.

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...