MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / gc_heap_oom

Function gc_heap_oom

tests/all/gc.rs:1473–1552  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1471#[test]
1472#[cfg_attr(any(miri, not(target_pointer_width = "64")), ignore)]
1473fn gc_heap_oom() -> Result<()> {
1474 if std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok() {
1475 return Ok(());
1476 }
1477
1478 let _ = env_logger::try_init();
1479
1480 for heap_size in [
1481 // Very small heap.
1482 1 << 16,
1483 // Bigger heap: 4 GiB
1484 1 << 32,
1485 ] {
1486 for pooling in [true, false] {
1487 let mut config = Config::new();
1488 config.wasm_function_references(true);
1489 config.wasm_gc(true);
1490 config.collector(Collector::Null);
1491 config.memory_reservation(heap_size);
1492 config.memory_reservation_for_growth(0);
1493 config.memory_guard_size(0);
1494 config.memory_may_move(false);
1495 config.gc_heap_reservation(heap_size);
1496 config.gc_heap_reservation_for_growth(0);
1497 config.gc_heap_guard_size(0);
1498 config.gc_heap_may_move(false);
1499
1500 if pooling {
1501 let mut pooling = crate::small_pool_config();
1502 pooling.max_memory_size(heap_size.try_into().unwrap());
1503 config.allocation_strategy(InstanceAllocationStrategy::Pooling(pooling));
1504 }
1505
1506 let engine = Engine::new(&config)?;
1507
1508 let module = Module::new(
1509 &engine,
1510 r#"
1511 (module
1512 (type $s (struct))
1513 (global $g (export "g") (mut i32) (i32.const 0))
1514 (func (export "run")
1515 loop
1516 struct.new $s
1517
1518 global.get $g
1519 i32.const 1
1520 i32.add
1521 global.set $g
1522
1523 br 0
1524 end
1525 )
1526 )
1527 "#,
1528 )?;
1529
1530 let mut store = Store::new(&engine, ());

Callers

nothing calls this directly

Calls 15

OkFunction · 0.85
is_okMethod · 0.80
collectorMethod · 0.80
gc_heap_reservationMethod · 0.80
gc_heap_guard_sizeMethod · 0.80
gc_heap_may_moveMethod · 0.80
allocation_strategyMethod · 0.80
small_pool_configFunction · 0.70
newFunction · 0.50
wasm_gcMethod · 0.45

Tested by

no test coverage detected