Skip to content

Fix a memory cycle when creating *Func#44

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-leak
Nov 20, 2020
Merged

Fix a memory cycle when creating *Func#44
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-leak

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

The global map for storing *Func objects previously stored *Store,
but that creates a reference cycle between the Rust and the Go heaps
which can't be cleaned up. Instead this commit updates the logic to
instead use a "thread local" variable to temporarily store the current
freelist during a call and moves the storage outside of the global
variables. This should allow everything to get garbage collected as
usual.

Closes #42

The global map for storing `*Func` objects previously stored `*Store`,
but that creates a reference cycle between the Rust and the Go heaps
which can't be cleaned up. Instead this commit updates the logic to
instead use a "thread local" variable to temporarily store the current
freelist during a call and moves the storage outside of the global
variables. This should allow everything to get garbage collected as
usual.

Closes bytecodealliance#42
@alexcrichton alexcrichton merged commit 986b514 into bytecodealliance:main Nov 20, 2020
@alexcrichton alexcrichton deleted the fix-leak branch November 20, 2020 20:40
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 in instance creation

1 participant