A TObjectList usually takes care to destroy its contents. Do not free your objects in this case. This will result in access violation when releasing the TObjectList , as it again tries to free the contained objects.
This behavior of the list of objects can be controlled in its constructor:
constructor TObjectList.Create(AOwnsObjects: Boolean);
Use this to indicate whether you want the list to own its content (meaning: it takes care to destroy the item when it is removed from the list or the list is destroyed) or not. A constructor without a parameter (which you probably used) sets it to true .
You probably just need a list of type TList , but for storing objects. If this is the case, then create your list as follows:
Allocations:= TObjectList.Create(False);
But if you want auto kill behavior, then just remove the for-loop. The list of objects will destroy your TXX_ALOC objects.
source share