[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[#63391] Access Modifiers (Internal Interfaces) — Daniel da Silva Ferreira <danieldasilvaferreira@...>
Hi,
3 messages
2014/06/28
[ruby-core:63153] [Backport21 - Backport #9934] [Open] High memory usage from file_expand_path_*
From:
ruby@...1.net
Date:
2014-06-13 18:45:26 UTC
List:
ruby-core #63153
Issue #9934 has been updated by Aman Gupta.
Tracker changed from Bug to Backport
Project changed from ruby-trunk to Backport21
Status changed from Closed to Open
----------------------------------------
Backport #9934: High memory usage from file_expand_path_*
https://bugs.ruby-lang.org/issues/9934#change-47210
* Author: Aman Gupta
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
All the file expansion routines use `EXPAND_PATH_BUFFER()` which allocates PATH_MAX bytes on the heap per invocation.
The strings returned by `File.expand_path` are never realloc'd after they are populated, so they continue using 4kb (on linux) per string.
In our rails app, 22MB of heap usage is due to expanded path name strings.
~~~
$ ruby -robjspace -e' puts ObjectSpace.dump(File.expand_path("/foo")) '
{"address":"0x007fa2b44dd6c8", "type":"STRING", "class":"0x007fa2b3f99608", "bytesize":4, "capacity":4098, "value":"/foo", "encoding":"US-ASCII", "memsize":4099, "flags":{"wb_protected":true}}
~~~
The following failing patch demonstrates the issue as well:
~~~
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 2c945ea..49be9de 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -458,6 +458,12 @@ class TestFileExhaustive < Test::Unit::TestCase
end
end
+ def test_expand_path_memsize
+ require "objspace"
+ path = File.expand_path("/foo")
+ assert_equal 5, ObjectSpace.memsize_of(path)
+ end
+
def test_expand_path_encoding
drive = (DRIVE ? 'C:' : '')
if Encoding.find("filesystem") == Encoding::CP1251
~~~
--
https://bugs.ruby-lang.org/