Forum > Databases
heaptrc and sqlite
ancamini:
hi, i have some problems using unit heaptrc with TSQLite3Connection and TSQLQuery.
i have written a console program thath uses messages and queues quite extensively and without saving messages in the db I have no leak.
When I save data into db I have leaks...records are ok into db, no error while saving... but when program terminates in trace.log i see leaking related to
db operations.
I have tried to create and open db in several ways...debugging step by step inserting and updating query.
All seems ok, but again on program termination i have log with a lot of block leak.
Could anyone put me on the right path to solve the problem?
Thanks for your time anyway
Carlo
Zvoni:
--- Quote from: ancamini on October 27, 2022, 02:52:47 pm ---hi, i have some problems using unit heaptrc with TSQLite3Connection and TSQLQuery.
i have written a console program thath uses messages and queues quite extensively and without saving messages in the db I have no leak.
When I save data into db I have leaks...records are ok into db, no error while saving... but when program terminates in trace.log i see leaking related to
db operations.
I have tried to create and open db in several ways...debugging step by step inserting and updating query.
All seems ok, but again on program termination i have log with a lot of block leak.
Could anyone put me on the right path to solve the problem?
Thanks for your time anyway
Carlo
--- End quote ---
I'm gazing into my crystal ball, but i don't see any code there, either....
ancamini:
Hi Zvoni...thank you for answering
I think it may be useful to attach the trace file. Perhaps for a more experienced person it can provide useful information.
I copied the routine, which is indicated in the log on line 263
Call trace for block $00007F8322912680 size 144
$00000000004025F7 INITDBCONFIG, line 263 of mainrack40.lpr
$000000000040328B DORUN, line 471 of mainrack40.lpr
$0000000000486B69
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function THBConfigDb.OpenDb: boolean;begin try if not Assigned(Fcnx) then begin Fcnx := TSQLite3Connection.Create(nil); Fcnx.Transaction := TSQLTransaction.Create(Fcnx); end else if Fcnx.Connected then Fcnx.Close(); if not Assigned(Fquery) then begin Fquery := TSQLQuery.Create(nil); Fquery.SQLConnection := Fcnx; end else if Fquery.Active then Fquery.Close; Fcnx.DatabaseName := FdirDb + FdbName; Fcnx.Open; Fcnx.Close(); Result := True; FdbOk := True; except Result := False; FdbOk := False; resetQry; resetCnx; end;end;
All the code is in a small class used to save messages read from 2 can bus channels.
Messages are pulled from a queue in the main program.
I can post all the code but maybe it's better if I put the one mentioned in the log.
Carlo
p.s.
sorry for my english but i got help from a translator
Zvoni:
When you exit/terminate your app, do you „Free“ (hint) the created objects (connection, transaction, query)?
Thaddy:
There are so many things wrong with that code that it makes it hard to debug. I miss a lot of try/finally and you make a lot of assumptions that the first line is always valid, which it isn't...
And heaptrc with the proper options (line info etc, and the sourcecode in place) would point you exactly to your leaks.
Navigation
[0] Message Index
[#] Next page