Hi Wagner,
How shoud I go about handling exceptions in a thread when trying to connect to a RemoteDB server if the server is not running? I have the following procedure that I am calling from a TTask to sync some data from a phone to a server. I'm testing it on windows at the moment but getting memory leaks and runtime error 216 when I close the program.
(Using Aurelius 4.0 RemoteDB 1.3)
procedure TGenCollectSync.SyncAll( AMsg: TProc< string > );
var
L, R: TObjectManager;
begin
L := TObjectManager.Create( TSQLiteConnection.CreateConnection );
try
L.Connection.Connect;
R := TObjectManager.Create( TRemoteDBFirebirdConnection.CreateConnection );
try
R.Connection.Connect;
UploadLoads( L, R, AMsg );
DownloadDataConfig( L, R, AMsg );
UploadLogData( L, R, AMsg );
finally
R.Free;
end;
finally
L.Free;
end;
end;
I'm calling it this way from within the TTask
try
GenCollectSync.SyncAll(
procedure( AMsg: string )
begin
TMSLogger.Trace( AMsg );
end
);
except
ECaptured := Exception( AcquireExceptionObject );
TThread.Queue( TThread.CurrentThread,
procedure
begin
raise ECaptured;
end );
end;
when closing the app on windows I get
---------------------------
Unexpected Memory Leak
---------------------------
An unexpected memory leak has occurred. The unexpected small block leaks are:
1 - 12 bytes: Unknown x 2
13 - 20 bytes: TSqliteDatabase x 1, TSemaphore x 1
21 - 28 bytes: TDBConnectionFactory x 1, TDBConnectionPool x 1, TDBConnectionPool.Create[0]$ActRec x 1, TPoolItemAnonymousFactory<XData.Aurelius.ConnectionPool.TDBConnectionWrapper> x 1, TDBConnectionWrapper x 1, TSQLiteConnection x 1, TObjectPool<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.TPoolItem<XData.Aurelius.ConnectionPool.TDBConnectionWrapper> x 1, TSQLiteConnection.CreateFactory$ActRec x 1, UnicodeString x 5
29 - 36 bytes: EAccessViolation x 1, TCriticalSection x 1
37 - 44 bytes: TTMSLoggerOutputFormats x 1, TMyAureliusOutputHandler x 1, UnicodeString x 2
45 - 52 bytes: TObjectPool<XData.Aurelius.ConnectionPool.TDBConnectionWrapper> x 1, TList<System.string> x 1
53 - 60 bytes: TObjectList<TMSLoggingCore.TTMSLoggerBaseOutputHandler> x 1, UnicodeString x 1, Unknown x 1
77 - 84 bytes: UnicodeString x 1
125 - 132 bytes: TTMSFMXLogger x 1
173 - 188 bytes: UnicodeString x 1
---------------------------
Error
---------------------------
Runtime error 216 at 00408756
---------------------------
OK
---------------------------
Thanks again
Steve