Skip to content

Instantly share code, notes, and snippets.

@nagachika
Created July 5, 2015 07:14
Show Gist options
  • Save nagachika/396fc77f95f0f4aac707 to your computer and use it in GitHub Desktop.
Save nagachika/396fc77f95f0f4aac707 to your computer and use it in GitHub Desktop.
1. ruby extconf.rb
2. make
3. ruby test11328.rb
4. watch memory usage of 3. process
You should reproduce Makefile (step 1) if you try another version of ruby.
#include "ruby/ruby.h"
static VALUE
bug_str_buf_cat(VALUE mod, VALUE str1, VALUE str2)
{
(void)mod;
rb_str_cat(str1, RSTRING_PTR(str2), RSTRING_LEN(str2));
return str1;
}
void
Init_bug11328(void)
{
VALUE mBug11328 = rb_define_module("Bug11328");
rb_define_singleton_method(mBug11328, "str_buf_cat", bug_str_buf_cat, 2);
}
require "mkmf"
create_makefile("bug11328")
require "./bug11328"
while true
str = "hello"
str2 = "foo"
10000.times do
Bug11328.str_buf_cat(str, str2)
end
GC.start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment