内存超出,同时使用实时多线。 [英] Memory exceeds, while using real time multi line.

查看:40
本文介绍了内存超出,同时使用实时多线。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

内存超出,同时在WPF中使用实时多行(40行)图表。 



我正在尝试为多线图建模在Wpf中使用chartingToolkit库。图表/图表必须运行至少8-10小时。存在线性进程内存增加的问题(高达800 MB或更多)。我需要从串行Com端口绘制实时数据(不同的
从站)。我从DispatcherTimer调用2进程UpadateValue和UpdateChart。
$




运行此程序时,进程内存随时间线性增加(超过900Mb)从任务经理观察.. !!)。
$


请给我一些解决记忆问题的事情。



非常感谢


我尝试过:

Memory exceeds, while using real time multi line (40 lines) charts in WPF. 

I am trying to model a multi line chart using chartingToolkit library in Wpf. The graph/chart has to run for atleast 8 -10 hrs. There is problem of linear process memory Increase (upto 800 MB or more). I need to plot real time data from serial Com Port (different slaves). I am calling 2 process UpadateValue and UpdateChart from DispatcherTimer.


While running this program, Process memory increases linearly with time (more than 900Mb observed from Task Manager..!!).

Please suggest me some things to resolve memory issue.

Thanks a Lot

What I have tried:

_______________________________________________
$
公共部分班级MainWindow :窗口

{

ObservableCollection< KeyValuePair< int,int>> Collection0 = new ObservableCollection< KeyValuePair< int,int>>();

ObservableCollection< KeyValuePair< int,int>> Collection1 = new ObservableCollection< KeyValuePair< int,int>>();

/ * ........ ..continue ............. * / $
ObservableCollection< KeyValuePair< int,int> > Collection39 = new ObservableCollection< KeyValuePair< int,int>>();
$


随机rnd = new Random();

public int i = 0;



public MainWindow()

{

InitializeComponent();



Parallel.Invoke(()=> {SetTimer1();});

Parallel.Invoke(()=> {SetTimer2();});

}



private void SetTimer1()

{

DispatcherTimer dispatcherTimer = new DispatcherTimer();

dispatcherTimer.Tick + = new EventHandler(ValueUpdate);

dispatcherTimer.Interval = new TimeSpan(0,0,0,2,0);

dispatcherTimer.Start();

}



private void SetTimer2()

{

DispatcherTimer dispatcherTimer = new DispatcherTimer();

dispatcherTimer.Tick + = new EventHandler(ChartUpdate ); $
dispatcherTimer.Interval = new TimeSpan(0,0,0,2,0);

dispatcherTimer.Start();

}



私人void ValueUpdate(object sender,EventArgs e)

{

int m = -40;

GC.Collect();

Collection0.Add(new KeyValuePair< int,int>(i,rnd.Next(m ++,m ++)));

Collection1.Add(new KeyValuePair< int,int>(i,rnd.Next(m ++,m ++)));

/*......continue......*/

Collection39.Add(new KeyValuePair< int,int>(i,rnd.Next(m ++,m ++)));

i = i + 1;

GC.Collect(); < br $>


}
$


无效ChartUpdate(对象发送者,EventArgs e)

{

GC.Collect();

LineChart0.DataContext = Collection0;

LineChart1.DataContext = Collection1;

/ * .....继续..... * /

LineChart39.DataContext = Collection39;

GC.Collect();

}

}

_______________________________________________
public partial class MainWindow : Window
{
ObservableCollection<KeyValuePair<int, int>> Collection0 = new ObservableCollection<KeyValuePair<int, int>>();
ObservableCollection<KeyValuePair<int, int>> Collection1 = new ObservableCollection<KeyValuePair<int, int>>();
/*..........continue.............*/
ObservableCollection<KeyValuePair<int, int>> Collection39 = new ObservableCollection<KeyValuePair<int, int>>();

Random rnd = new Random();
public int i = 0;

public MainWindow()
{
InitializeComponent();

Parallel.Invoke(() => { SetTimer1(); });
Parallel.Invoke(() => { SetTimer2(); });
}

private void SetTimer1()
{
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(ValueUpdate);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 2, 0);
dispatcherTimer.Start();
}

private void SetTimer2()
{
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(ChartUpdate);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 2, 0);
dispatcherTimer.Start();
}

private void ValueUpdate(object sender, EventArgs e)
{
int m = -40;
GC.Collect();
Collection0.Add(new KeyValuePair<int, int>(i, rnd.Next(m++, m++)));
Collection1.Add(new KeyValuePair<int, int>(i, rnd.Next(m++, m++)));
/*......continue......*/
Collection39.Add(new KeyValuePair<int, int>(i, rnd.Next(m++, m++)));
i = i + 1;
GC.Collect();

}

void ChartUpdate(object sender, EventArgs e)
{
GC.Collect();
LineChart0.DataContext = Collection0;
LineChart1.DataContext = Collection1;
/*.....continue.....*/
LineChart39.DataContext = Collection39;
GC.Collect();
}
}

推荐答案


内存超出,而在WPF中使用实时多行(40行)图表。 
$


我正在尝试使用Wpf中的chartingToolkit库来表示多线图表。 

Memory exceeds, while using real time multi line (40 lines) charts in WPF. 

I am trying to model a multi line chart using chartingToolkit library in Wpf. 


这篇关于内存超出,同时使用实时多线。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆