garbageman 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/garbageman.gemspec +2 -2
- data/lib/garbageman/collector.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWI5MGIyNWM4YzY5N2RkNzcyYjVjMWQ3NTJhYTg0YzAxYjJhNTVmMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2Y5MjA0MTAzZWViOTg5YzMxZGQyMjAzNmQwYjgzNmE5NGU5MTA1Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmQ0MmIzMGMyYTcwZDA2ZTYyNGQyYWE2MWZkMWM5YTExZGU0YTk1YjM5MmEy
|
10
|
+
MWJmMDJjZDNiMzM1ZjhmODZjOGY0MTFmYzNkMDk4MzBiZWRkMDM2N2ZhNDgy
|
11
|
+
ZWY3YTAzYzc4MTE5OTQ4YmI4YmRiOTEyMGIwZDhjM2MyOGU5NDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2IwZjMzMzkzZWMyNDNhODY2ZjVjOTEzNWY5MDVjYzFhODdhMjMwMWVlZjVh
|
14
|
+
OTVhZjJhNWFmZjZmNDIyYTViNmQzYjQ4YzIwN2E0NzJhZmQ2YTEwNTljMDhh
|
15
|
+
ODRjNWZhMjZhNTVkYjRhMjBjZjA5MjcyNDA4NTkwY2YzZTdlZjY=
|
data/garbageman.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: garbageman 0.
|
5
|
+
# stub: garbageman 0.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "garbageman"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/lib/garbageman/collector.rb
CHANGED
@@ -91,12 +91,13 @@ module GarbageMan
|
|
91
91
|
|
92
92
|
write_gc_yaml server_index, STARTING
|
93
93
|
debug "starting gc"
|
94
|
+
memory_used = @show_gc_times ? process_resident_memory_size_in_kb : 0
|
94
95
|
starts = Time.now
|
95
96
|
GC.enable
|
96
97
|
Config.gc_starts.times { GC.start; sleep Config.gc_sleep }
|
97
98
|
@last_gc_finished_at = Time.now
|
98
99
|
diff = (@last_gc_finished_at - starts) * 1000
|
99
|
-
info "GC took #{'%.2f' % diff}ms for #{@request_count} requests" if @show_gc_times
|
100
|
+
info "GC took #{'%.2f' % diff}ms for #{@request_count} requests, and freed #{memory_used - process_resident_memory_size_in_kb}kb of memory" if @show_gc_times
|
100
101
|
write_gc_yaml server_index, NEXT_SERVER
|
101
102
|
|
102
103
|
after_gc_callbacks.each(&:call)
|
@@ -112,6 +113,14 @@ module GarbageMan
|
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
116
|
+
def process_resident_memory_size_in_kb
|
117
|
+
headers, stats = `ps v #{Process.pid}`.split "\n"
|
118
|
+
return 0 unless headers && stats
|
119
|
+
headers = headers.strip.gsub(/ +/, ' ').split(' ')
|
120
|
+
stats = stats.strip.gsub(/ +/, ' ').split(' ')
|
121
|
+
Hash[headers.zip(stats)]['RSS'].to_i
|
122
|
+
end
|
123
|
+
|
115
124
|
def create_gc_yaml
|
116
125
|
return unless server_index
|
117
126
|
return if File.exists?(Config.gc_yaml_file) && ! current_server?
|