Fix memory leak in File.expand_path
File.expand_path leaks the dir if the encodings are not compatible.
For example:
Encoding.default_external = Encoding::UTF_16BE 10.times do 100_000.times do File.expand_path("./a") rescue end puts `ps -o rss= -p #{$$}` end
Before:
12288 15488 18656 21872 25056 28240 31392 34688 37856 41056
After:
9680 9728 9728 9792 9792 9792 9792 9792 9792
Fix memory leak in File.expand_path
File.expand_path leaks the dir if the encodings are not compatible.
For example:
Before:
After: