Click here to Skip to main content
11,488,877 members (78,076 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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:

  thread start(method1); // thread run method1
  delegate(method2); // run method2
Posted 14-Nov-12 6:09am
digimanus at 14-Nov-12 11:12am
where is your GC.Collect?
Sergey Alexandrovich Kryukov at 14-Nov-12 13:02pm
Christian Graus at 14-Nov-12 14:03pm
NEVER call this, if you have to, it means your code is broken.
Sergey Alexandrovich Kryukov at 14-Nov-12 14:44pm
That's why asked "why", same thought...
qqq2195819 at 14-Nov-12 21:25pm
in while, To delegate can contribute little
Christian Graus at 14-Nov-12 11:23am
Why do you need a thread to do this ? Why do you care about 50 megabytes ? The memory usage in the task manager is not really accurate, you know.
qqq2195819 at 14-Nov-12 21:23pm
Is really of memory may take up more!
A thread scan or wait for data, then applied to listbox inside, I don't want to let the main thread feign death
Christian Graus at 15-Nov-12 7:51am
AS others have said, we cannot optimise pseudo code. Your question is meaningless. However, having a delegate called without fail in a while(true) will obviously run until it has no resources
Sergey Alexandrovich Kryukov at 14-Nov-12 13:03pm
Nothing is clear. Not a question. What language is this? Pseudo-code?
Christian Graus at 14-Nov-12 14:03pm
I assumed it was funky C# 4.5 code :P
Sergey Alexandrovich Kryukov at 14-Nov-12 14:45pm
Nooo-o! :-)
qqq2195819 at 14-Nov-12 21:28pm
C# , Because the code too much, Leaving only the main,Can be easier to understand
Sergey Alexandrovich Kryukov at 14-Nov-12 22:00pm
It cannot help. Nothing is clear at all.
n.podbielski at 15-Nov-12 3:52am
So you want others to optimize pseudo code? Really?
qqq2195819 at 15-Nov-12 9:59am
Hope to provide ideas, solve the problem of memory footprint
n.podbielski at 15-Nov-12 12:00pm
Since .net is not much about memory utilization as much as performance, since c# is not much about memory either (gc, thread safety takes memory also) maybe you should write this in C++ pointers are less demanding. Or C since it is even lighter. Or assembler. Then you can use registers an CPU cache without use of memory at all.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

this code untimely hangup every thing..

just add

  delegate(method2); // run method2

and it will work smoothly
qqq2195819 at 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 at 19-Nov-12 17:50pm
Total gibberish. A big vote of 1, sorry.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 489
1 OriginalGriff 328
2 Sascha Lefèvre 135
3 _Asif_ 125
4 _duDE_ 121
0 Sergey Alexandrovich Kryukov 9,308
1 OriginalGriff 8,375
2 Sascha Lefèvre 3,334
3 Maciej Los 2,996
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100