Project

General

Profile

Feature #11664

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

`rb_autoload_value` rb_autoload_value may be safer by preventing premature GC.    It 
 can also be more efficient by passing a pre-frozen string that 
 can be deduped using `rb_fstring`. rb_fstring.    Common autoload callers (e.g. 
 rubygems, rdoc) already use string literals as the file 
 argument. 

 There seems to be no reason to expose `rb_autoload_value` rb_autoload_value to the 
 public C API since autoload is not performance-critical. 
 Applications may declare autoloads in Ruby code or via 
 `rb_funcall`; rb_funcall; so merely deprecate `rb_autoload` rb_autoload without exposing 
 `rb_autoload_value` rb_autoload_value to new users. 

 Running: `valgrind valgrind -v ruby -rrdoc -rubygems -e exit` exit 
 shows a minor memory reduction (32-bit userspace) 

 before: 

 ~~~ 
   

   in use at exit: 1,600,621 bytes in 28,819 blocks 
 total heap usage: 55,786 allocs, 26,967 frees, 6,693,790 bytes allocated 
 ~~~ 

 after: 

 ~~~ 
   

   in use at exit: 1,599,778 bytes in 28,789 blocks 
 total heap usage: 55,739 allocs, 26,950 frees, 6,692,973 bytes allocated 
 ~~~

Back