Click here to Skip to main content
13,002,163 members (86,075 online)
Rate this:
Please Sign up or sign in to vote.
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:

  thread start(method1); // thread run method1
  delegate(method2); // run method2
Posted 14-Nov-12 5:09am
digimanus 14-Nov-12 11:12am
where is your GC.Collect?
Sergey Alexandrovich Kryukov 14-Nov-12 13:02pm
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...
qqq2195819 14-Nov-12 21:25pm
in while, To delegate can contribute little
Christian Graus 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 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 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 14-Nov-12 13:03pm
Nothing is clear. Not a question. What language is this? Pseudo-code?
Christian Graus 14-Nov-12 14:03pm
I assumed it was funky C# 4.5 code :P
Sergey Alexandrovich Kryukov 14-Nov-12 14:45pm
Nooo-o! :-)
qqq2195819 14-Nov-12 21:28pm
C# , Because the code too much, Leaving only the main,Can be easier to understand
Sergey Alexandrovich Kryukov 14-Nov-12 22:00pm
It cannot help. Nothing is clear at all.
n.podbielski 15-Nov-12 3:52am
So you want others to optimize pseudo code? Really?
qqq2195819 15-Nov-12 9:59am
Hope to provide ideas, solve the problem of memory footprint
n.podbielski 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 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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2017
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