Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Direct Memory Buffer Leak in File IO #863
Apparently the JRuby File class allocates NIO direct memory buffers, but doesn't release them. I wrote the following test program (on jruby-1.7.4 on Java 1.7 on OSX 10.8.4):
i=0 loop do i=i+1 File.open('/dev/null','r') do |infile| end puts i sleep 0.1 end
When I run this with a restricted MaxDirectMemorySize using:
it crashes very quickly:
I tried the same thing by simply opening and closing a FileInputStream, and the memory usage stays constant. I used https://blogs.oracle.com/nbprofiler/entry/new_memory_buffer_plugin_for to monitor buffer usage.
I also ran this on Java 6 and Java 7. Java 6 stabilized very early at around 112MB. I let it run for about 8000 iterations (after dropping the sleep down to 0.01s). Java 7 stabilized higher, around 171MB, after running up to 109k iterations. I'm convinced that this is fixed as well.
Free free to confirm with master and reopen if there are any further issues. Thanks for the report!