This repository was archived by the owner on Aug 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Unbounded Memory Leak #106
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
Making two large allocations, then dropping them in the order they were allocated leaks memory in wee_alloc, but not in default allocator.
Steps to Reproduce
Native code
- Clone this branch of my app: https://github.com/CraigMacomber/wee_alloc_leak_png
cargo run
- GB of memory is consumed per second
- Comment out use of wee_alloc global_allocator.
cargo run
- Memory use does not increase.
Wasm
- Clone this branch of my app: https://github.com/noencke/uuid-cluster/tree/wee_alloc_leak
npm run serve
(runs wasm-pack, npm install and webpack dev server)- go to localhost:8080 in browser
- click the button (it's the only thing on the page) to increase heap by 131 MB each time
Expected Behavior
Second time allocations are made uses free list.
Actual Behavior
Repeated allocations grow heap infinitely.
Additional Context
This seems similar to an issue mentioned in #105
Heap size does not increase if using default allocator.
Rust source for example is just:
extern crate wee_alloc;
// Use `wee_alloc` as the global allocator.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
pub fn leak_test() {
// This leaks when using wee_alloc
let a = Box::new([0; 85196]);
let b = Box::new([0; 80000]);
drop(a);
drop(b);
}
fn main() {
loop {
leak_test();
}
}
finnbear, UltimateDoge5, Tarnadas, mikialex, runiq and 12 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working