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

Optimization pass for better garbage collection #189

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Apr 19, 2024

This PR tries to do some optimization for better garbage collection, based on testing with VisuaVM.

  • Close WolfSSLInputStream/WolfSSLOutputStream when SSLSocket.close() is called. This releases the internal references to WolfSSLSession and WolfSSLSocket to allow easier garbage collection of these Input/OutputStream objects.
  • Release/reset WolfSSLEngineHelper state when WolfSSLSocket.close() is called, removing internal object references and allowing easier garbage collection.
  • Set clientSNIRequested and ctx to null inside WolfSSLSession when freeSSL() is called, potentially reducing the size of WolfSSLSession objects in memory until they are garbage collected.
  • Remove finalizer method from WolfSSLInternalVerifyCb class. This is not needed and slows down garbage collection, since objects with finalizers are put in a different queue.
  • Add close() to WolfSSLServerSocket which will close the underlying WolfSSLSocket if called and free up resources earlier than at garbage collection time.

This PR also refactors WolfSSLSession.useALPN() at the JNI level to better guarantee ALPN list is null terminated.

@JacobBarthelmeh JacobBarthelmeh merged commit 3dcfb63 into wolfSSL:master Apr 24, 2024
36 checks passed
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.

3 participants