Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GC stats for shady objects in memory
When number of shady objects cross shady objects limit, a major GC is triggered. Knowing the trend of shady objects in memory is useful to understand why major GCs happen. Shady objects ============= When an object survives a GC, it's considered an old object and Ruby will stop marking it in future minor GCs. Now there is a chance that an old object may refer to a new object, for example, there is a global array into which we push a local object. Since the global array is old, the marking algorithm won't check this array in the next minor GC. This means the local object which was newly created, but refereneced in the array will be GCd since the marking algorithm didn't find any reference to it. To solve this, Ruby adds a write barrier around each object so Ruby knows when something in the old generation was touched, and remember to include it in future marking runs. But objects created directly from C extensions do not have write barriers, so these are kind of "shady" in the sense that Ruby has no guarantee that these objects hold references to other objects. So Ruby remembers to include shady objects when running the marking algorithm.
- Loading branch information