-
Notifications
You must be signed in to change notification settings - Fork 284
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
feat: change to singleton instance for TdsParser.cs and TdsParserStat… #2420
base: main
Are you sure you want to change the base?
Conversation
…eObjectManaged.cs, TdsParserStateObjectNative.cs to reduce memory leak for those objects
@dotnet-policy-service agree company="Siigo SAS" |
|
@@ -209,6 +209,9 @@ internal TdsParser(bool MARS, bool fAsynchronous) | |||
DataClassificationVersion = TdsEnums.DATA_CLASSIFICATION_NOT_ENABLED; | |||
} | |||
|
|||
public static TdsParser Instance(bool MARS, bool fAsynchronous) | |||
=> new TdsParser(MARS, fAsynchronous); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something, but every time this method is called it's going to return a new instance of TdsParser
.
I don't understand how this change would help. All it does is move the new into a helper function. Have you been able to track down the retention root for the instances that you see increasing? This is purely managed code so you're probably not really seeing a leak you're seeing unexpected retention. |
Change to singleton instance for TdsParser.cs and TdsParserStateObjectManaged.cs, TdsParserStateObjectNative.cs to reduce memory leaks for those objects.
Evidence:
Before the changes, each execution generated instances of TdsParser and TdsParserStateObjectManaged, which remained unused in memory, leading to a memory leak.
Before changes
This memory leak was observed in services deployed on k8s with Linux pods.
Memory leak
After the changes, each execution reused the objects TdsParser and TdsParserStateObjectManaged.
After changes