Back to Catalog
The asynchronous operation is. net4.5 launch of the new term, in fact, this thing has long ago, it is in the final analysis through the thread pool to achieve, will be a large task into a number of small any block, each thread in parallel processing one of them, after the completion of the results told the main thread, after the. More convenient, but, concurrency (lead, multithreading) is not applicable everywhere, improper use, there may be a lot of serious consequences!
Look at my program, this guy has taken up 2.6G of memory space, very scary!
The cause of this problem is that I do not have the thread this thing clear, in a call dense environment, using multi-threading, you know, this thread, the line constructor will have n multiple threads, processing speed I do not feel the ascension, but the memory eat very serious, The reason for this is because you have too many threads for your work .
So, multi-threaded, parallel, asynchronous these things are not applicable everywhere, in the call dense when you can use it, because it will eat a lot of your memory, if not to use, please limit the maximum number of thread pool, this value can be controlled within 10.
Here is an example of multithreading to eat memory
while(true) { //Threadpool.setmaxthreads (ten);//Limit maximum worker threads and I/O threadsThreadPool.QueueUserWorkItem (NewWaitCallback ((a) ={concurrentdictionary<string, sendingresult> test2 =Newconcurrentdictionary<string, sendingresult>(); Test2. TryAdd (Guid.NewGuid (). ToString (),NewSendingresult {batchnumber=Guid.NewGuid (). ToString (), DbName="Zzl", Endid=1, Startid=1, TableName="Zzl", Occurdate=DateTime.Now,}); })); if(DateTime.Now.Minute = = Geneva) { Break; } }
View a Task Manager
This situation has improved when I have restricted the working thread
and If the operation is frequent (rotation service) work, if you do not use multi-threading, but based on what not to eat memory, performance is better!
Thank you for reading!
Back to Catalog
Foundation is the weight of the heavy-multi-Threading Cost ~ My memory has been eaten!