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

Fix memory leak when creating and destroying a lot of context #790

Merged
merged 1 commit into from
May 5, 2023

Conversation

normanmaurer
Copy link
Member

Motivation:

During introducing #759 I missed to add a free call which did introduce a small memory leak. This was not noticable for most users as creating and destroying of SSL context is usually very rare. That said some users might still do this and so notice the leak.

Modifications:

  • Add missing free(...) call to match calloc(...)
  • Move code of one function to the other as it was the only calling function. This simplifies the code and makes it less error-prone

Result:

Fixes #788

Motivation:

During introducing #759 I missed to add a free call which did introduce a small memory leak. This was not noticable for most users as creating and destroying of SSL context is usually very rare. That said some users might still do this and so notice the leak.

Modifications:

- Add missing free(...) call to match calloc(...)
- Move code of one function to the other as it was the only calling function. This simplifies the code and makes it less error-prone

Result:

Fixes #788
@normanmaurer
Copy link
Member Author

/cc @slandelle @notdryft

Copy link

@franz1981 franz1981 left a comment

Choose a reason for hiding this comment

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

@normanmaurer you can give a shot to the async profiler native memory leak branch!

@normanmaurer normanmaurer merged commit fd8fb2a into main May 5, 2023
@normanmaurer normanmaurer deleted the fix_mem_leak branch May 5, 2023 10:07
@notdryft
Copy link

notdryft commented May 5, 2023

We're currently testing it against the async profiler nativemem mode ourselves!

@normanmaurer
Copy link
Member Author

normanmaurer commented May 5, 2023

I could not reproduce a leak anymore with this pulled in. Once you confirm it as well I will do a release

@franz1981
Copy link

Great @notdryft let me know if that worked too!

normanmaurer added a commit that referenced this pull request Sep 19, 2023
Motiviation:

In the past we removed the usage of apr by static linking against stdc++. While at first this seemed like a good idea it has proven to introduce problems on various platforms.
Because of these problems we should better revert the changes and just link against apr again.

Modifications:

- Revert "Fix memory leak when creating and destroying a lot of context (#790)" fd8fb2a.
- Revert "Fix possible corruption / segfault when using atomics (#774)"  11ff708.
- Revert "Fix segfault which was caused by not creating the ticket_keys_new atomic (#772)" 196f935.
- Revert "Fix format usage" eecaaa8.
- Revert "Link libstdc++ statically on linux" a288f03.
- Revert "rename functions for consistency" 7ee7804.
- Revert "Remove dependency on apr by using c++11 / c++14 features" 8740651.

Result:

Fixes #798 , #789
normanmaurer added a commit that referenced this pull request Sep 21, 2023
Motiviation:

In the past we removed the usage of apr by static linking against
stdc++. While at first this seemed like a good idea it has proven to
introduce problems on various platforms. Because of these problems we
should better revert the changes and just link against apr again.

Modifications:

- Revert "Fix memory leak when creating and destroying a lot of context
(#790)" fd8fb2a.
- Revert "Fix possible corruption / segfault when using atomics (#774)"
11ff708.
- Revert "Fix segfault which was caused by not creating the
ticket_keys_new atomic (#772)" 196f935.
- Revert "Fix format usage" eecaaa8.
- Revert "Link libstdc++ statically on linux"
a288f03.
- Revert "rename functions for consistency"
7ee7804.
- Revert "Remove dependency on apr by using c++11 / c++14 features"
8740651.
- Update APR version

Result:

Fixes #798 ,
#789
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.

Memory leak on SslProvider instantiation with netty-tcnative-boringssl-static
3 participants