Closed brianpursley closed 5 months ago
Welcome @brianpursley!
It looks like this is your first PR to kubernetes-client/csharp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.
You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.
You can also check if kubernetes-client/csharp has its own contribution guidelines.
You may want to refer to our testing guide if you run into trouble with your tests not passing.
If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to Kubernetes. :smiley:
Hmm, i think I can't do this:
using var httpRequest = new HttpRequestMessage
... because this is not awaited ...
return SendRequestRaw("", httpRequest, cancellationToken);
So the using
disposes httpRequest
before SendRequestRaw
has executed.
SendRequest
should probably use async/await, but I think that is a different problem. I will update this PR to remove that change.
OK, removed the using
change. I ran the profile again and it was unaffected, so maybe that change doesn't really make a difference anyway.
Good catch
/LGTM
All modified and coverable lines are covered by tests :white_check_mark:
:exclamation: No coverage uploaded for pull request base (
master@3dae1cf
). Click here to learn what that means.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: brianpursley, tg123
The full list of commands accepted by this bot can be found here.
The pull request process is described here
While not recommended, if you repeatedly create a Kubernetes client inside of a loop, there appears to be a memory leak, even if you dispose it.
This PR adds the following to fix this:
.Dispose()
forFirstMessageHandler
.Dispose()
forHttpClientHandler
Dispose()
methodAddsUsing
forhttpRequest
(while unrelated to the Kubernetes client lifecycle, I believe this should also be disposed)Possible fix for #1539 (I suspect that issue is not related only to aot).
Test Results
I tested this using the following console program and running in Rider using memory profiling (sampled allocations):
Before the fix
Memory increases slowly, eventually reaching ~163MB by the end of the program:
After the fix
Memory holds stead around ~123MB: