Components have an owner in order to simplify the process of managing their memory.
When a component is created with an Owner component (which means, the constructor´s parameter Owner
is not nil
), such a component is added to a list in the owner component (property TComponent.Components
). From this moment on the programmer does not need to care about releasing the just created component, since it´s owner will free it when the owner itself is freed.
When a component is created without an owner, then the programmer becomes responsible to explicitly free it in some moment.
So, the affirmative about memory leaks you found is correct, but it could be complemented with "as long as AOwner
is not nil
".
If there is a leak in your code regarding a component, it´s because the owner component is not being freed, so no owned components will be free either. In this cases, you have to look the bug in the owner component´s life cicle, not the owned component´s.