The count error of the loop is because the process of free changes in ComponentCount, so it can only reverse Free.
For i: = form1.componentcount-1 Downto 0 Do Begin if Form1.Components [I] is Tedit the form1.components [i] .free;