Kouhei Sutou
null+****@clear*****
Mon Sep 30 16:55:54 JST 2013
Kouhei Sutou 2013-09-30 16:55:54 +0900 (Mon, 30 Sep 2013) New Revision: aa60dd405239cfa0a9561380e8c746273b48f6ac https://github.com/groonga/groonga-query-log/commit/aa60dd405239cfa0a9561380e8c746273b48f6ac Message: memory-leak-detector: use alloc_count in status instead of RSS as indicator Modified files: lib/groonga/query-log/memory-leak-detector.rb Modified: lib/groonga/query-log/memory-leak-detector.rb (+11 -11) =================================================================== --- lib/groonga/query-log/memory-leak-detector.rb 2013-09-30 14:49:17 +0900 (a320651) +++ lib/groonga/query-log/memory-leak-detector.rb 2013-09-30 16:55:54 +0900 (fcb63cd) @@ -55,28 +55,28 @@ module Groonga def check_command(client, command) command["cache"] = "no" - current_memory_usage = nil + current_n_allocations = nil @options.n_tries.times do |i| client.execute(command) - previous_memory_usage = current_memory_usage - current_memory_usage = memory_usage - next if previous_memory_usage.nil? - if current_memory_usage > previous_memory_usage + previous_n_allocations = current_n_allocations + current_n_allocations = n_allocations(client) + next if previous_n_allocations.nil? + if current_n_allocations > previous_n_allocations max_n_digits = [ - compute_n_digits(previous_memory_usage), - compute_n_digits(current_memory_usage), + compute_n_digits(previous_n_allocations), + compute_n_digits(current_n_allocations), ].max puts("detect a memory leak:") puts("Nth try: #{i}") - puts("previous: %*d" % [max_n_digits, previous_memory_usage]) - puts(" current: %*d" % [max_n_digits, current_memory_usage]) + puts("previous: %*d" % [max_n_digits, previous_n_allocations]) + puts(" current: %*d" % [max_n_digits, current_n_allocations]) puts(command.original_source) end end end - def memory_usage - `ps -o rss --no-header --pid #{@options.pid}`.to_i + def n_allocations(client) + client.status.n_allocations end def compute_n_digits(n) -------------- next part -------------- HTML����������������������������...Download