- changed title to Memory Leak in Marshmallow FiredacAdapter
Memory Leak in Marshmallow FiredacAdapter
In a previous issue I reported an issue with using Transactions with the Firedac Adapter. Linas quickly applied my suggested fix, which was greatly appreciated. Unfortunately I did not forsee a memory leak that my suggested fix caused.
Since we are now creating a new TFDTransaction each time the user calls BeginTransaction off of the session and this is not an interface type, it needs to be destroyed when the IDBTransaction interface goes out of scope. Also it needs to be freed after the call to the inherited destroy as the parent uses the Transaction Object during the destroy process to rollback the transaction if it is still running when the destroy is invoked.
So Here is my code to fix this issue: Unit - Spring.Persistence.Adapters.Firedac. Add a destructor and free the FTransaction instance after inherited is called.
destructor TFireDACTransactionAdapter.Destroy;
begin
inherited;
{
TFlo - This must be after the call to inherited as the FTransaction is
used in the inherited destroy to try and rollback the transaction, If this
is placed before inherited it will throw AV exceptions.
}
FreeAndNil(FTransaction);
end;
Comments (5)
-
reporter -
reporter Or of course fix it however you see fit. AQTime is what surfaced this issue to me.
-
repo owner - changed status to open
I think only providing an additional ownsobject parameter to the ctor will work properly.
-
reporter Sure thing.
--
-
repo owner - changed status to resolved
fixed issue
#118→ <<cset 39d656a10622>>
- Log in to comment