gocd/gocd — pull request #668 by arvindsv (2014-10-17 20:51:03+00:00)
Title: #000 - Ruby string -> Java string in view cache.

When fragment caching is used, as mentioned in the Rails guide
http://guides.rubyonrails.org/caching_with_rails.html#fragment-caching,
the actual fragment is cached as a Ruby String. In JRuby, this means
that the RubyString class (http://jruby.org/apidocs/org/jruby/RubyString.html)
is used.

When a RubyString class is used in a long-lived cache, it has
potentially bad consequences. In this case, because of JRuby string
copy-on-write semantics, some of these strings had 3MB of memory stored
for a string as small as 6000 characters (because RubyString uses
ByteList, which had a big byte array as a buffer, which it indexes into.

When the Go fragment cache tried to cache 500 pipelines, each taking
about 3MB to cache (instead of about the usual 6 to 10 KB), the memory
usage went through the roof.

This commit brings back the old JRuby and Rails way of using
java.lang.String for the fragment cache, instead of using RubyString.
Just for fragment caches.