denoland / deno_core

The core engine at the heart of Deno
MIT License
309 stars 99 forks source link

`UnboundScript` - `create_code_cache()` leaks memory #779

Open dsherret opened 5 months ago

dsherret commented 5 months ago

Run and close a worker in a loop and you'll see this happening.

image

image

https://github.com/v8/v8/blob/cbc1b57b90ba1db080f0a045adcefce04c1f21e5/src/snapshot/code-serializer.cc#L669

JacobZwang commented 2 months ago

Is this why creating new JsRuntimes leaks memory? Is there a solution to this? Here's a simple example that steadily increases memory usage over time.

use deno_core::{JsRuntime, RuntimeOptions};

fn main() {
    for i in 0..1000 {
        let _js_runtime = JsRuntime::new(RuntimeOptions {
            ..Default::default()
        });
    }
}