Skip to content

Commit

Permalink
fix: drop wee malloc to remove memory leaks
Browse files Browse the repository at this point in the history
Repeatedly calling this library causes unbounded memory growth.
Wee-alloc has known memory leak issues.
See rustwasm/wee_alloc#106

Rust's standard library allocator can be used instead.
  • Loading branch information
RossWilliams committed Oct 25, 2022
1 parent 815c569 commit 81d69f0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 62 deletions.
59 changes: 3 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Expand Up @@ -11,7 +11,7 @@ license = "Apache-2.0"
crate-type = ["cdylib", "rlib"]

[features]
default = ["wee_alloc", "console_error_panic_hook"]
default = ["console_error_panic_hook"]

[profile.release]
lto = true
Expand All @@ -20,7 +20,6 @@ opt-level = 's'
[dependencies]
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
brotli = "3.3"
wee_alloc = { version = "0.4", optional = true }
console_error_panic_hook = { version = "0.1", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
4 changes: 0 additions & 4 deletions src/lib.rs
Expand Up @@ -4,10 +4,6 @@ use brotli;
use wasm_bindgen::prelude::*;
use serde::{Serialize, Deserialize};

#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

pub fn set_panic_hook() {
#[cfg(feature="console_error_panic_hook")]
console_error_panic_hook::set_once();
Expand Down

0 comments on commit 81d69f0

Please sign in to comment.