Skip to content
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

(#478) allocate once and reuse memory for env vars #524

Merged
merged 4 commits into from
Jan 23, 2024

Conversation

KeterSCP
Copy link
Contributor

Closes #478

@ForNeVeR ForNeVeR self-requested a review January 22, 2024 21:22
@ForNeVeR ForNeVeR self-assigned this Jan 22, 2024
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great! One minor issue though.

{
return null;
}

return StdIoFunctions.MarshalStr(Environment.GetEnvironmentVariable(str));
_envVarsStorage ??= InitEnvVarsStorage();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little concerned about the thread safety here. If two threads enter this field, then _envVarsStorage will just silently leak.

Let's just make it Lazy? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Fixed it

@ForNeVeR ForNeVeR assigned KeterSCP and unassigned ForNeVeR Jan 22, 2024
@KeterSCP KeterSCP requested a review from ForNeVeR January 22, 2024 21:56
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ForNeVeR ForNeVeR merged commit 515521b into ForNeVeR:main Jan 23, 2024
3 checks passed
@KeterSCP KeterSCP deleted the allocate-envs-once branch January 28, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of memory leaks during getenv
2 participants