Stream: pascal
Topic: Tx server issues
Jose Costa Teixeira (Jul 13 2021 at 19:45):
Looking at the code and trying to find what could be reasons for eventual leaks, I found a few things that could be worth looking at, but I need another pair of eyes to look at these:
Jose Costa Teixeira (Jul 13 2021 at 19:47):
- I see quite some lines like SomeObj.doSomething( var1, var2, TSomeOtherObject.create(var3)).
I think this causes the SomeOtherObject to be created but I was not sure whether they will get properly disposed of.
Example:
FOthers.Add(ics.systemUri, TFhirCodeSystemProvider.create(ffactory.link, TFHIRCodeSystemEntry.Create(FFactory.wrapCodeSystem(FValueSet.Resource.Link))));
Jose Costa Teixeira (Jul 13 2021 at 19:51):
A very common case of this happens with HTTPLanguages, lines like this:
cs.displays(code, displays, THTTPLanguages.Create('en'));
Jose Costa Teixeira (Jul 13 2021 at 19:51):
(this happens many times)
Jose Costa Teixeira (Jul 13 2021 at 19:54):
- Another thing I noticed is that sometimes the object that is a result of a function is created and it is not destroyed in the function (so it needs to be destroyed elsewhere).
result := TResourceWithReference.Create(id, parser.parseResource(s));
Sometimes we do see some functions that do a
try
result = TSomeObject.create(whatever)
finally
result.free
I do not know if this explicit destroy is needed
Jose Costa Teixeira (Jul 13 2021 at 19:58):
These being very common findings, I don't know if any of these is causing a leak, but we could start looking at it. However, we cannot isolate one by one, nor I know if they should even be fixed.
One way to move forward would be to try and detect what kind of requests cause memory footprint to grow.
Jose Costa Teixeira (Jul 13 2021 at 19:59):
And to do this, we can just throw 1000s of requests to the server until we find one request that causes a leak. We do it one at a time
Jose Costa Teixeira (Jul 13 2021 at 20:00):
I don't know what are the types of requests that we see on the server, but I guess we have some GETs and mostly operations?
Jose Costa Teixeira (Jul 13 2021 at 20:01):
we could select a few of those, but we should do it on a replica of the server, which actually contains the necessary content to work (at least part of SNOMED, LOINC...)
Jose Costa Teixeira (Jul 13 2021 at 20:03):
Sadly, I do not have the server working since it moved to Lazarus. If we could get a replica of our server as a VM that I could run locally, i can setup jmeter to throw stuff at the server to try
Grahame Grieve (Jul 13 2021 at 20:29):
THTTPLanguages is a record, not an object, so it doesn't live on the stack
Grahame Grieve (Jul 13 2021 at 20:29):
lists own the objects, and free them when they are removed from the lsit
Grahame Grieve (Jul 13 2021 at 20:30):
The server is not going down because it runs out of memory, so far as I can figure
Grahame Grieve (Jul 13 2021 at 20:30):
the server still compiles and runs under delphi
Jose Costa Teixeira (Jul 13 2021 at 20:50):
I'll get started on this, getting the server to run. Should I do this in a VM for us all to share, for future debugging? just because the setup is not that trivial.
Rob Hausam (Jul 13 2021 at 20:53):
I've been able to get the code to run under FPC - but I haven't done the rest of the setup yet with SQL Server, etc. I'm just using the Console for the moment.
Jose Costa Teixeira (Aug 05 2021 at 06:29):
https://tx.fhir.org/r4/ValueSet/iso3166-1-3/$validate-code?system=urn:iso:std:iso:3166&code=USA
Jose Costa Teixeira (Aug 05 2021 at 06:30):
At a first glance, I think the issue would come from a line like this:
procedure TCountryCodeServices.Close(ctxt: TCodeSystemProviderFilterPreparationContext);
begin
raise ETerminologyTodo.create('TCountryCodeServices.Close');
end;
Rob Hausam (Aug 05 2021 at 16:46):
Yes, that seems likely the case.
Last updated: Apr 12 2022 at 19:14 UTC