Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
2.25/5 (4 votes)
See more:
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:

C#
main()
{
  thread start(method1); // thread run method1
}
method1()
{
 while(true)
  delegate(method2); // run method2
}
method2()
{
  listbox.items.add("test");
}
Posted
Comments
Herman<T>.Instance 14-Nov-12 11:12am    
where is your GC.Collect?
Sergey Alexandrovich Kryukov 14-Nov-12 13:02pm    
Why?
--SA
Christian Graus 14-Nov-12 14:03pm    
NEVER call this, if you have to, it means your code is broken.
Sergey Alexandrovich Kryukov 14-Nov-12 14:44pm    
That's why asked "why", same thought...
--SA
qqq2195819 14-Nov-12 21:25pm    
in while, To delegate can contribute little

1 solution

this code untimely hangup every thing..

just add

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


and it will work smoothly
 
Share this answer
 
Comments
qqq2195819 15-Nov-12 10:03am    
Each time you use Delegate will have Memory increases
,My purpose is to reduce the memory occupancy, thread sleep, just slow down the speed of execution, and finally memory will increase,Entrust call after hundreds of times in task manager observation, a significant increase
Sergey Alexandrovich Kryukov 19-Nov-12 17:50pm    
Total gibberish. A big vote of 1, sorry.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900