Feature Description
Summary
Expose a public API to configure Boa’s garbage collector (GC) at runtime. This allows embedders and advanced users to tune memory management by setting allocation thresholds and used-space triggers.
Note: This aims to resolve the GC configuration TODO currently located in the engine initialization path (e.g., lib.rs:63).
Motivation
- Enables embedders to control GC behavior for different workloads.
- Provides the required groundwork for future GC redesigns and benchmarking.
- Aligns with best practices in other major JavaScript engines (e.g., V8, SpiderMonkey).
Requirements
Acceptance Criteria
Example code
This Rust code should work and allow the embedder to successfully configure the GC upon context creation:
use boa_engine::ContextBuilder;
use boa_engine::gc::GcConfig;
let custom_gc_config = GcConfig::new(10_000_000, 80);
// or you can: GcConfig::default().with_threshold(10_000_000).with_used_space_percentage(80);
let mut context = ContextBuilder::new()
.gc_config(custom_gc_config)
.build()
.expect("Failed to build context");
// Also a point to remmember The engine should now respect the custom thresholds during execution.
Feature Description
Summary
Expose a public API to configure Boa’s garbage collector (GC) at runtime. This allows embedders and advanced users to tune memory management by setting allocation thresholds and used-space triggers.
Note: This aims to resolve the GC configuration
TODOcurrently located in the engine initialization path (e.g.,lib.rs:63).Motivation
Requirements
GcConfigstruct with fields for threshold and used-space percentage.gc_config()andset_gc_config()functions to get/set the current thread-local GC config.ContextBuilderso embedders can set the GC configuration at context creation.Acceptance Criteria
ContextBuildercorrectly applies to the newly created context.Example code
This Rust code should work and allow the embedder to successfully configure the GC upon context creation: