ko1 / ruby-lang.org wrote:
>     * gc.c (objspace_malloc_increase): should not invoke
>       garbage_collect_with_gvl() here on non-ruby threads.
>       Should just ignore the malloc_increase.
>       This issue is pointed by Eric Wong [ruby-core:61519].

Also, how about using a objspace->want_gc_soon flag in these situations.

I have also been thinking about having Ruby detect best places to GC
and defer GC until those points:

1) when the stack is shallow
2) when a thread is about to sleep

But multiple threads makes it hard to predict the best points.

Maybe objspace should track allocations per-thread, not globally.
Threads which allocate most would also run GC most;
ideally when 1) and 2) are true.