diff --git a/benchmark/parse.yaml b/benchmark/parse.yaml index 8818b50c..8c85ed17 100644 --- a/benchmark/parse.yaml +++ b/benchmark/parse.yaml @@ -6,7 +6,7 @@ contexts: prelude: require 'rexml' - name: master gems: - strscan: 3.0.8 + strscan: 3.0.9 prelude: | $LOAD_PATH.unshift(File.expand_path("lib")) require 'rexml' @@ -19,7 +19,7 @@ contexts: RubyVM::YJIT.enable - name: master(YJIT) gems: - strscan: 3.0.8 + strscan: 3.0.9 prelude: | $LOAD_PATH.unshift(File.expand_path("lib")) require 'rexml' diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index 71b08f99..db78a124 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -149,11 +149,7 @@ def initialize(arg, block_size=500, encoding=nil) def read begin - # NOTE: `@scanner << readline` does not free memory, so when parsing huge XML in JRuby's DOM, - # out-of-memory error `Java::JavaLang::OutOfMemoryError: Java heap space` occurs. - # `@scanner.string = @scanner.rest + readline` frees memory that is already consumed - # and avoids this problem. - @scanner.string = @scanner.rest + readline + @scanner << readline rescue Exception, NameError @source = nil end diff --git a/rexml.gemspec b/rexml.gemspec index 2ba1c64d..c76bedbe 100644 --- a/rexml.gemspec +++ b/rexml.gemspec @@ -55,7 +55,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.5.0' - spec.add_runtime_dependency("strscan", ">= 3.0.8") + spec.add_runtime_dependency("strscan", ">= 3.0.9") spec.add_development_dependency "benchmark_driver" spec.add_development_dependency "bundler"