委托和内存过载 [英] Delegate and memory overload

查看:55
本文介绍了委托和内存过载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用线程来列出添加的数据,

没用委托内存占用11-12M

使用委托内存占用50 + M(对委托的重复调用)

Gc不能完全释放内存,

帮我 !优化代码或其他解决方案

伪代码:

I use thread, to list added data,

No use Delegate memory occupancy 11-12M

Use Delegate memory occupancy 50 + M(Repeated calls to Delegate)

Gc can not be completely free memory,

help me ! Optimization code, or other solutions

Pseudo code:

main()
{
  thread start(method1); // thread run method1
}
method1()
{
 while(true)
  delegate(method2); // run method2
}
method2()
{
  listbox.items.add("test");
}

推荐答案

此代码不合时宜地挂断每件事.
只需添加

this code untimely hangup every thing..

just add

method1()
{
 while(true)
{
  thread.sleep(1000);
  delegate(method2); // run method2
}
}



它会顺利运行



and it will work smoothly


这篇关于委托和内存过载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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