From: Eric Wong Date: 2018-05-11T05:43:30+00:00 Subject: [ruby-core:86988] Re: [Ruby trunk Bug#14745] High memory usage when using String#replace with IO.copy_stream janko.marohnic@gmail.com wrote: > def initialize(content) > @io = StringIO.new(content) > end > > def read(length, outbuf) > chunk = @io.read(length) Finally, I always assumed your example is a contrived case and you're dealing with an interface somewhere (not StringIO) which doesn't accept a destination buffer for .read. Fwiw, I encountered a similar problem with Net::HTTP and Zlib::GzipReader earlier this year and made r61665 to ensure outbuf got used all the way down the call chain. Sometimes I guess modifying/fixing interfaces is the only way to go. (unless we can do escape analysis, but I'm not sure how feasible it is with a dynamic language) Unsubscribe: