TObjectManager has a cache system?

A few days back i set the property


MyObjectManager.OwnsObjects := False

Whats happens now is that i request the manager to find a object at some point in my code, like this:

//this will return a TUser if found
Result := Self.FModel.FindUser(ALogin);

If i understand correctly the returned class will not be owned by the manager as i demanded.
Later on, i request again for a user, but if it is the same user it seems that the TObjectManager uses some kind of cache system and retrieves the same instance not a new one.

What happend next is a multi free error since i considered that the instance was mine responsability and i freed both of them.

So at the end is not clear to me what happens in background, why istead of return a new class the TObjectManager make use of the previously requested class if it is the same.

thx in advance.

Cache is not related with object management. You just have to be aware of it and adapt your code accordingly.

"OwnsObjects" just means that manager will not destroy objects inside it. But it doesn't mean the cache will be deactivated. It still needs to manage object state to perform operations correctly.