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 leaks, make extension types more efficient #803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PThorpe92
Copy link
Contributor

@PThorpe92 PThorpe92 commented Jan 28, 2025

I was baffled previously, because any time that free was called on a type from an extension, it would hang even when I knew it wasn't in use any longer, and hadn't been double free'd.

After #737 was merged, I tried it again and noticed that it would no longer hang... but only for extensions that were staticly linked.

Then I realized that we are using a global allocator, that likely wasn't getting used in the shared library that is built separately that won't inherit from our global allocator in core, causing some symbol mismatch and the subsequent hanging on calls to free.

This PR adds the global allocator to extensions behind a feature flag in the macro that will prevent it from being used in wasm and staticly linked environments where it would conflict with limbos normal global allocator. This allows us to properly free the memory from returning extension functions over FFI.

This PR also changes the Extension type to a union field so we can store int + float values inline without boxing them.

any additional tips or thoughts anyone else has on improving this would be appreciated 👍

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.

1 participant