Commit 43cec6e
committed
fix(sandbox): allocation budget actually fires — Mono lacks per-thread GC counter
GC.GetAllocatedBytesForCurrentThread returns 0 unconditionally under Unity's Mono
(verified empirically), so the F-08 allocation-bomb backstop could never trigger in
either VM guard: bombs ran to a real OutOfMemory or the wall-clock timeout. Both
guards now baseline/sample GC.GetTotalMemory(false) — a cheap managed-heap read that
is also thread-agnostic (the async Lua-CSharp VM migrates between pool threads).
Heap total is process-wide and noisy, so the default budget is raised 64MB -> 256MB:
editor background allocation over a 2s window tripped the old threshold in the
infinite-loop test (false positive), while real concat-doubling bombs blow past
256MB within a few iterations either way.
Verified: full EditMode suite 1583/1583 green, including both
AllocationBomb_ConcatDoubling tests (budget fires, not timeout/OOM) and the
untouched infinite-loop step/timeout test.1 parent 9ad67d7 commit 43cec6e
3 files changed
Lines changed: 4 additions & 4 deletions
File tree
- Assets/CoreAIMods/Runtime/Sandbox
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments