Skip to content

Commit

Permalink
Merge pull request #32 from Shopify/ruby-mem-leak
Browse files Browse the repository at this point in the history
Change call_into_ruby_mem_leak to use eval
  • Loading branch information
peterzhu2118 committed May 2, 2024
2 parents 7413a23 + 8f88ed6 commit 6f344fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions test/ruby_memcheck/ext/ruby_memcheck_c_test_one.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ static VALUE c_test_one_uninitialized_value(VALUE _)

static VALUE c_test_one_call_into_ruby_mem_leak(VALUE obj)
{
char str[20];
for (int i = 0; i < 10000; i++) {
sprintf(str, "foobar%d", i);
rb_intern(str);
}
VALUE string = rb_eval_string("String.new(capacity: 10_000)");
RSTRING(string)->as.heap.ptr = NULL;

return Qnil;
}

Expand Down
8 changes: 3 additions & 5 deletions test/ruby_memcheck/ext/ruby_memcheck_c_test_two.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ static VALUE c_test_two_uninitialized_value(VALUE _)

static VALUE c_test_two_call_into_ruby_mem_leak(VALUE obj)
{
char str[20];
for (int i = 0; i < 10000; i++) {
sprintf(str, "foobar%d", i);
rb_intern(str);
}
VALUE string = rb_eval_string("String.new(capacity: 10_000)");
RSTRING(string)->as.heap.ptr = NULL;

return Qnil;
}

Expand Down

0 comments on commit 6f344fa

Please sign in to comment.