[前][次][番号順一覧][スレッド一覧]

ruby-changes:38947

From: ngoto <ko1@a...>
Date: Thu, 25 Jun 2015 18:36:04 +0900 (JST)
Subject: [ruby-changes:38947] ngoto:r51028 (trunk): * test/lib/envutil.rb (Test::Unit::Assertions#assert_no_memory_leak):

ngoto	2015-06-25 18:35:46 +0900 (Thu, 25 Jun 2015)

  New Revision: 51028

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51028

  Log:
    * test/lib/envutil.rb (Test::Unit::Assertions#assert_no_memory_leak):
      NO_MEMORY_LEAK_ENVS is moved to Memory::NO_MEMORY_LEAK_ENVS
      to reduce child executions during test-all on Solaris.
    
    * test/lib/memory_status.rb (Memory::NO_MEMORY_LEAK_ENVS): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/test/lib/envutil.rb
    trunk/test/lib/memory_status.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51027)
+++ ChangeLog	(revision 51028)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 25 18:25:41 2015  Naohisa Goto  <ngotogenome@g...>
+
+	* test/lib/envutil.rb (Test::Unit::Assertions#assert_no_memory_leak):
+	  NO_MEMORY_LEAK_ENVS is moved to Memory::NO_MEMORY_LEAK_ENVS
+	  to reduce child executions during test-all on Solaris.
+
+	* test/lib/memory_status.rb (Memory::NO_MEMORY_LEAK_ENVS): ditto.
+
 Thu Jun 25 17:32:33 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_method.c (rb_method_entry_create): need to call
Index: test/lib/envutil.rb
===================================================================
--- test/lib/envutil.rb	(revision 51027)
+++ test/lib/envutil.rb	(revision 51028)
@@ -442,29 +442,6 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L442
         assert_warning(*args) {$VERBOSE = false; yield}
       end
 
-      case RUBY_PLATFORM
-      when /solaris2\.(?:9|[1-9][0-9])/i # Solaris 9, 10, 11,...
-        bits = [nil].pack('p').size == 8 ? 64 : 32
-        if ENV['LD_PRELOAD'].to_s.empty? &&
-            ENV["LD_PRELOAD_#{bits}"].to_s.empty? &&
-            (ENV['UMEM_OPTIONS'].to_s.empty? ||
-             ENV['UMEM_OPTIONS'] == 'backend=mmap') then
-          envs = {
-            'LD_PRELOAD' => 'libumem.so',
-            'UMEM_OPTIONS' => 'backend=mmap'
-          }
-          args = [
-            envs,
-            "--disable=gems",
-            "-v", "-",
-          ]
-          _, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
-          if status.exitstatus == 0 && err.to_s.empty? then
-            NO_MEMORY_LEAK_ENVS = envs
-          end
-        end
-      end #case RUBY_PLATFORM
-
       def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
         require_relative 'memory_status'
         token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
@@ -477,9 +454,9 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L454
           *args,
           "-v", "-",
         ]
-        if defined? NO_MEMORY_LEAK_ENVS then
+        if defined? Memory::NO_MEMORY_LEAK_ENVS then
           envs ||= {}
-          newenvs = envs.merge(NO_MEMORY_LEAK_ENVS) { |_, _, _| break }
+          newenvs = envs.merge(Memory::NO_MEMORY_LEAK_ENVS) { |_, _, _| break }
           envs = newenvs if newenvs
         end
         args.unshift(envs) if envs
Index: test/lib/memory_status.rb
===================================================================
--- test/lib/memory_status.rb	(revision 51027)
+++ test/lib/memory_status.rb	(revision 51028)
@@ -108,4 +108,32 @@ module Memory https://github.com/ruby/ruby/blob/trunk/test/lib/memory_status.rb#L108
       status
     end
   end
+
+  # On some platforms (e.g. Solaris), libc malloc does not return
+  # freed memory to OS because of efficiency, and linking with extra
+  # malloc library is needed to detect memory leaks.
+  #
+  case RUBY_PLATFORM
+  when /solaris2\.(?:9|[1-9][0-9])/i # Solaris 9, 10, 11,...
+    bits = [nil].pack('p').size == 8 ? 64 : 32
+    if ENV['LD_PRELOAD'].to_s.empty? &&
+        ENV["LD_PRELOAD_#{bits}"].to_s.empty? &&
+        (ENV['UMEM_OPTIONS'].to_s.empty? ||
+         ENV['UMEM_OPTIONS'] == 'backend=mmap') then
+      envs = {
+        'LD_PRELOAD' => 'libumem.so',
+        'UMEM_OPTIONS' => 'backend=mmap'
+      }
+      args = [
+              envs,
+              "--disable=gems",
+              "-v", "-",
+             ]
+      _, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
+      if status.exitstatus == 0 && err.to_s.empty? then
+        NO_MEMORY_LEAK_ENVS = envs
+      end
+    end
+  end #case RUBY_PLATFORM
+
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]