Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib::Deflate #deflate memory leak #3962

Open
petr-tichy opened this issue Jun 10, 2016 · 3 comments
Open

Zlib::Deflate #deflate memory leak #3962

petr-tichy opened this issue Jun 10, 2016 · 3 comments

Comments

@petr-tichy
Copy link

Environment

Tested on jruby 1.7.25 (1.9.3p551) 2016-04-13 867cb81 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 +jit [darwin-x86_64] and jruby 1.7.19
Possibly present in all 1.7 versions

Expected Behavior

On MRI #deflate emits chunks as needed.

Actual Behavior

This buffers all output until finish is called.
Taken from Zip::Deflater.<< in rubyzip gem:

require 'zlib'

prng = Random.new
data = prng.bytes(2**20)

zlib_deflater = ::Zlib::Deflate.new(::Zlib::DEFAULT_COMPRESSION, -::Zlib::MAX_WBITS)

200.times do
  buffer = zlib_deflater.deflate(data)
  puts "output kB: #{buffer.bytesize / 1024.0}" unless buffer.empty?
end

buffer = zlib_deflater.finish
puts "output from finish kB: #{buffer.bytesize / 1024.0}" unless buffer.empty?
@petr-tichy
Copy link
Author

Present also in jruby 9.1.9.0-SNAPSHOT (2.3.3) 2017-04-06 1ad761b Java HotSpot(TM) 64-Bit Server VM 25.60-b23 on 1.8.0_60-b27 [darwin-x86_64]

@headius
Copy link
Member

headius commented Sep 18, 2019

This does seem to still be an issue on JRuby 9.2.8.0.

@headius
Copy link
Member

headius commented Sep 18, 2019

Note that running this on recent Java 8 will just use a bunch of memory; I tried choking max heap down for this and the example from rubyzip/rubyzip#322 and it wasn't difficult to get OOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants