Skip to content

Help Rubinius out with collecting garbage #202

Closed
wants to merge 2 commits into from

2 participants

@evanphx
evanphx commented May 13, 2011

This patch adds a one_shot_only method which has run_machine not run a while(true) loop forever. Rubinius uses this mode so that run_machine can return and thus allow all objects accessed within run_machine to be collected as garbage. Because of the way ruby allows C extensions to work, Rubinius must keep a strong reference to all objects referenced by a C function. run_machine looping forever causes a memory leak and thus doing the loop in ruby allows those things to be freed.

@sodabrew
sodabrew commented Feb 3, 2015

@evanphx @brixen Do you know if this is still a problem with current Rubinius?

@evanphx
evanphx commented Feb 3, 2015

@sodabrew Yeah, this is still a problem. (wow this PR is 3.5 years old and the first comment is an hour ago).

@sodabrew
sodabrew commented Feb 3, 2015

So the issue is that you need the extension to "come up for air" once in a while, back into Ruby space, so that you can garbage collect?

I wonder if we could always pump the machine this way, or if it would kill MRI performance (I suspect it would, but...).

I hope it wouldn't be too crazy to ask you to rebase to current master? :) I just landed #568 so unit tests run on Rubinius now!

@sodabrew sodabrew added this to the v1.0.7 milestone Feb 4, 2015
@evanphx
evanphx commented Feb 4, 2015

@sodabrew Yes, that's correct. I suspect it wouldn't hurt performance on MRI either, given that most of the time is spent waiting on the IO events anyway.

I'll see about doing a rebase.

@evanphx
evanphx commented Feb 4, 2015

@sodabrew There ya go, applies to master now.

@sodabrew
sodabrew commented Aug 3, 2015

Resolved by #617

@sodabrew sodabrew closed this Aug 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.