Commit c60c4de
committed
fix: event loop GC via threshold-based gc_check_trigger_export
After removing gc_check_trigger from timer ticks (caused SIGSEGV from
register-held values being missed by conservative stack scanner), GC had
no trigger point for long-running services. Memory grew unbounded.
This adds gc_check_trigger_export() — an extern "C" wrapper around the
existing threshold-based gc_check_trigger — and calls it from the main
event loop AFTER both timer ticks have returned. At this point, all live
JS values are safely stored in module globals, closure boxes, or timer
root lists (not in registers), so the conservative scanner finds them.
The threshold check (arena >= 64MB or malloc objects >= 10k) ensures GC
only fires when needed, not on every 10ms loop tick.
Verified: RSS stable at ~90MB (vs 40MB/min growth without, and SIGSEGV
with the timer-tick approach).1 parent 33561c2 commit c60c4de
3 files changed
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
801 | | - | |
| 801 | + | |
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
806 | 816 | | |
807 | 817 | | |
808 | 818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10710 | 10710 | | |
10711 | 10711 | | |
10712 | 10712 | | |
| 10713 | + | |
| 10714 | + | |
| 10715 | + | |
| 10716 | + | |
| 10717 | + | |
| 10718 | + | |
| 10719 | + | |
| 10720 | + | |
10713 | 10721 | | |
10714 | 10722 | | |
10715 | 10723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
0 commit comments