-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Fix memory leak in TraceableHttpClient for environments with profiling #43287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hey! I think @fancyweb has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
…Client services (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] fix missing kernel.reset tag on TraceableHttpClient services | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Replaces #43287 Commits ------- 2951f53 [HttpClient] fix missing kernel.reset tag on TraceableHttpClient services
Thanks for the help. It seems that with that tag, the |
That's correct, but what you want is that TraceableHttpClient is reset when calling reset on the container, which what the tag should do, isn't it? |
The |
is that a real world use case? as of now, resetting is supposed to be managed by the container, as resetting only a subset of leaking services makes little sense. |
It was for debugging a production memory leak, where we'd want to reset the profilers and leave only the memory leaks that shouldn't be there. So that we could better evaluate the production-level leak (which could for example be in a misconfigured Though I agree it's a bit of a specific use case. As far as I'm concerned the current setup is fine then, as we have enough options to approach this problem (like running a local environment in |
Each
DataCollector
implementation usually holds the Traceable versions of certain interfaces.These are used by the profiler to display the traces of calls. For long running processes, this can lead to increased memory usage over time. To prevent memory leakage, the
reset()
method can be called. For example on theprofiler
service, which holds services tagged withdata_collector
. Which is used by the new Messenger reset feature as well.On
reset
, each DataCollector removes it's data from memory, and that of the Traceable classes that it holds. See for example theEventDataCollector
.Now the
HttpClientDataCollector
seems to skip resetting the data of theTraceableHttpClient
(s) that it holds. This DataCollector only resets its own data. There doesn't seem to be any other class/service callingreset
on theTraceableHttpClient
. Therefor it should probably be done by this DataCollector? Unless there is a specific reason this is skipped, that I'm not aware about that.I've tested this setup to confirm that without the reset on the clients, the memory keeps increasing, and with the reset being called, the memory no longer increases.
Something else I found curious but might not be related:
Note the tag
http_client.client
being present.Now listing services by that tags gives none:
Though the client is injected into
data_collector.http_client
, which searches services on that tag as well.