You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Heapy diff can yield both false positives
and false negatives due to keying on heap
pointers. This is difficult to fix, so
we're just documenting this for now.
Refs zombocom#31
Copy file name to clipboardexpand all lines: README.md
+14
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,20 @@ Allocated STRING 9991 objects of size 399640/491264 (in bytes) at: scratch.rb:24
47
47
Writing heap dump diff to output.json
48
48
```
49
49
50
+
#### Limitations
51
+
52
+
Due to how the garbage collector in MRI manages objects on the Ruby heap, `heapy diff` may produce incomplete
53
+
or incorrect diffs under the following circumstances:
54
+
55
+
1.**Heap compaction.** When compacting the Ruby heap either manually via `GC.compact` or with auto-compaction
56
+
enabled, heapy cannot produce accurate diffs, because objects may move into different heap slots and will appear as
57
+
newly allocated even if they weren't. In general, any mechanism that moves existing objects from one heap slot to
58
+
another will invalidate diff reports. Always turn off compaction before taking the `<after>` heap dump.
59
+
1.**Temporary allocations.** Diffs might omit objects from an `<after>` dump if Ruby allocated them into heap slots that were
60
+
previously occupied by different objects in the `<before>` dump, and which were then deallocated between both dumps.
61
+
To minimize the chance of this happening, triggering a major GC three or more times between heap dumps can help
62
+
tenuring survivors and thus stabilizing the heap prior to taking a diff.
63
+
50
64
### Read a Heap Dump
51
65
52
66
Step 1) Generate a heap dump. You could [do this manually](http://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby). Or you can use a tool like [derailed_benchmarks](https://github.com/schneems/derailed_benchmarks)
0 commit comments