diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2024-01-16 15:22:03 -0500 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2024-01-16 16:19:43 -0500 |
| commit | 5471f99eead4dd77f1d418eca04d7656bb97f01d (patch) | |
| tree | 0a14aa98b404dd64ae0082d06a15bbf64240f558 /spec/ruby/core/basicobject/instance_eval_spec.rb | |
| parent | 7b6731b1bb7c8fab72580f92450eea6e4cc3d943 (diff) | |
[PRISM] Fix memory leak when compiling file
There is a memory leak when passing a file to
RubyVM::InstructionSequence.compile_prism because it does not free the
mapped file.
For example:
require "tempfile"
Tempfile.create(%w"test_iseq .rb") do |f|
f.puts "name = 'Prism'; puts 'hello'"
f.close
10.times do
1_000.times do
RubyVM::InstructionSequence.compile_prism(f)
end
puts `ps -o rss= -p #{$$}`
end
end
Before:
27968
44848
61408
77872
94144
110432
126640
142816
159200
175584
After:
11504
12144
12592
13072
13488
13664
14064
14368
14704
15168
Diffstat (limited to 'spec/ruby/core/basicobject/instance_eval_spec.rb')
0 files changed, 0 insertions, 0 deletions
