By Pavel Tskekov
Let's see how the garbage collector works.
I've made an application "Garbage Show" in which we have a class MyTextBoxClass, which derives from the TextBox class.
In my newly created class I've put a static variable : instanceCount, which count
current instances of the class.
A Timer components displays how many the current instances are.
When I push the "Create New Instances" button I create a thousand instances, but
because I set them all to a single variable , the count of the instances should be 1. BUT it stays 1000. This is because of the Garbage Collector.
Try clicking several times on the "Create New Instances" button to see the moment
in which GC kills many of the instances.
Download GarbageShow.zip