Skip to content

Commit 56e0963

Browse files
committed
Ignore empty samples in retained collector
1 parent 641294c commit 56e0963

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ext/vernier/vernier.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,12 @@ class RetainedCollector : public BaseCollector {
10741074
void record(VALUE obj) {
10751075
RawSample sample;
10761076
sample.sample();
1077+
if (sample.empty()) {
1078+
// During thread allocation we allocate one object without a frame
1079+
// (as of Ruby 3.3)
1080+
// Ideally we'd allow empty samples to be represented
1081+
return;
1082+
}
10771083
int stack_index = frame_list.stack_index(sample);
10781084

10791085
object_list.push_back(obj);

test/test_retained_memory.rb

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def test_nested_collections
7373
assert_operator result1.samples.size, :>, result2.samples.size
7474
end
7575

76+
def test_thread_allocation
77+
result = Vernier.trace_retained do
78+
Thread.new { }.join
79+
end
80+
end
81+
7682
def test_nothing_retained
7783
result = Vernier.trace_retained do
7884
100.times {

0 commit comments

Comments
 (0)