Object's memory footprint release

  Recently filled pit write socket, the server after receiving the data memory for increased almost year on year. Dictionary object receiving data with the received data packets are saved together. Very simple thing, After saving the object dereference memory is recovered . Then dereference, memory is not released. So the dictionary empty, dereference, memory is not released, your hands (this is more than just point attempts, mmp). Opening the vs-> Analysis -> Performance Profiler, memory usage analysis, is indeed a dictionary takes up memory. Then finally he found himself ignored the object has a callback that is used to initiate a notification after a few exist, the callback blank GC finally to work. Before a special record before, then posted here: quoted delegate instance method also references a particular object, when calling the instance method through the delegate, the object becomes this in the call. https://www.cnblogs.com/xuanhu/p/10591382.html .

  You can make an interesting attempt: Form1 have a commission, two buttons; Form2 have a function that only do one thing, ShowMessageBox; Fomr1 1 button click event to instantiate a Form2, Form2 and add the function to Form1 delegate invocation list, and then Form2.Dispose, then call the delegate. 2 Form1 button click event put forward a for loop, button 1.PerformClick. Click Form1 to run the 2 button to see the results, should be more profound impression.

Guess you like

Origin www.cnblogs.com/xuanhu/p/11241699.html