Skip to content

Commit

Permalink
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/jruby/test_ffi_pointer_leak.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'ffi'
require 'test/unit'

class TestFFIMemoryLeak < Test::Unit::TestCase
java_import java.lang.management.ManagementFactory
def test_4625
5.times { JRuby.gc }
initial = ManagementFactory.memory_mx_bean.non_heap_memory_usage.used
i = 0
10_000_000.times do
ptr = FFI::MemoryPointer.from_string('some random test string')
ptr.free
i += 1
end
5.times { JRuby.gc }
memory = ManagementFactory.get_memory_mx_bean.get_non_heap_memory_usage.used
assert (memory - initial) / initial < 0.10, "memory after allocations was more than 10% higher"
end
end
1 change: 1 addition & 0 deletions test/slow.index
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jruby/test_command_line_switches
jruby/test_launching_by_shell_script
jruby/test_ffi_pointer_leak

0 comments on commit 6b6f27b

Please sign in to comment.