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

Fixed memory leak on boxed bytes #1629

Merged
merged 2 commits into from
May 15, 2024

Conversation

gfusee
Copy link
Contributor

@gfusee gfusee commented May 15, 2024

Abstract

The BoxedBytes currently allocates manually a u8 slice before wrapping it into a Box. This has the drawback of making Rust unable to free the memory once the BoxedBytes is dropped.

Changes

  • The BoxedBytes::allocate function has been removed
  • BoxedBytes::zeros now only uses safe Rust and uses the Vec logic to allocate a slice
  • All the usages of BoxedBytes::allocate have been replaced by BoxedBytes::zeros. Since BoxedBytes is not used on WASM contracts anymore this should have no impact on the code. On the RustVM there is no limit on allocations so this has a negligible performance cost

@BiancaIalangi BiancaIalangi self-requested a review May 15, 2024 14:22
@andrei-marinica andrei-marinica merged commit 35f4b6f into multiversx:master May 15, 2024
11 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.

4 participants