From: Eric Wong Date: 2014-06-12T03:32:25+00:00 Subject: [ruby-core:63119] Re: [ruby-trunk - Bug #9934] High memory usage from file_expand_path_* ruby@tmm1.net wrote: > This is the best I could come up with. Definitely not ideal since it > allocates another ruby object. What about using rb_str_resize? rb_str_resize may work even better if we remove the 1024 byte threshold and trust the realloc implementation to do the right thing. Additionally, rb_str_freeze may also be smarter and force a resize unconditionally, as keeping the buffer is useless for frozen strings. Not sure if changing rb_str_freeze this way breaks compatibility (but we should be able to safely resize for rb_fstring, at least).