Trigger full GC from CodeManager to fix memory use #2225

Merged
merged 3 commits into from Mar 25, 2013

Conversation

Projects
None yet
2 participants
@ryoqun
Member

ryoqun commented Mar 21, 2013

Just read the commit message. It should be enough to understand the issue.

Also, this pull request contains two other clean-up commits.

Closes #2224.

ryoqun added some commits Mar 21, 2013

Trigger full GC from CodeManager to fix memory use
There is a possible situation of excessive memory usage.

It's when many CompiledCode objects are repeatedly created and internalized. In
that case, many MachineCode objects are internally created but never collected.
Thus, memory usage increases forever.

The following test code exhibits the problem:

    prc = proc do
    end

    loop do
      prc.block.instance_variable_set(:@compiled_code,
                                      prc.block.compiled_code.dup)
      prc.call
    end

In such a situation, CompiledCode objects are collected immediately as young
objects by GC. It means that the full (mature) GC is never triggered.

When CompiledCode is internalized, it creates a MachineCode object, a kind of
CodeResource, which is managed and garbage-collected by CodeManager.

Currently, CodeManager only collects unneeded code resources in full (mature)
GC. So, if there is no trigger for the full GC, code resources are never
collected. This is usually fine because code resources are created very
spontaneously under normal conditions.

To fix this, when centain number of code resources (currently, 64 MiB in data
size wise) are newly added, trigger the full GC from CodeManager.

Closes #2224.

dbussink added a commit that referenced this pull request Mar 25, 2013

Merge pull request #2225 from ryoqun/compiled-code-leak
Trigger full GC from CodeManager to fix memory use

@dbussink dbussink merged commit cbe57a7 into rubinius:master Mar 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment