bleak_house 3.4 → 3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v3.5. Explain when you need more frames. Use a cross-platform version of 'which'. Slight accuracy improvement.
3
+
2
4
  v3.4. Clearer output descriptions; work around a Marshal bug on x64; fix for missing immortal leaks.
3
5
 
4
6
  v3.3. Build Ruby in gem install step; bundle Ruby 1.8.6 source; fixes for truncated final frames.
data/Manifest CHANGED
@@ -20,7 +20,6 @@ lib/bleak_house/support/rake.rb
20
20
  lib/bleak_house.rb
21
21
  LICENSE
22
22
  LICENSE_BSD
23
- LICENSE_RUBY
24
23
  Manifest
25
24
  Rakefile
26
25
  README
data/README CHANGED
@@ -5,7 +5,7 @@ A library for finding memory leaks.
5
5
 
6
6
  == License
7
7
 
8
- Copyright 2007 Cloudburst, LLC. See the included LICENSE file. Portions copyright 2006 Eric Hodel and used with permission. See the included LICENSE_BSD file. Portions copyright 2007 TOMITA Masahiro and used with permission. See the included LICENSE_RUBY file.
8
+ Copyright 2007 Cloudburst, LLC. See the included LICENSE file. Portions copyright 2006 Eric Hodel and used with permission. See the included LICENSE_BSD file.
9
9
 
10
10
  The public certificate for this gem is at http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem.
11
11
 
@@ -1,4 +1,6 @@
1
1
 
2
+ # Extension abuse in order to build our patched binary as part of the gem install process.
3
+
2
4
  if RUBY_PLATFORM =~ /win32|windows/
3
5
  raise "Windows is not supported."
4
6
  end
@@ -8,7 +10,15 @@ tmp = "/tmp/"
8
10
 
9
11
  require 'fileutils'
10
12
 
11
- if `which ruby-bleak-house` =~ /no ruby-bleak-house in/
13
+ def which(basename)
14
+ # system('which') is not compatible across Linux and BSD
15
+ ENV['PATH'].split(File::PATH_SEPARATOR).detect do |directory|
16
+ path = File.join(directory, basename.to_s)
17
+ path if File.exist? path
18
+ end
19
+ end
20
+
21
+ unless which('ruby-bleak-house')
12
22
 
13
23
  Dir.chdir(tmp) do
14
24
  build_dir = "bleak_house"
@@ -29,14 +39,10 @@ if `which ruby-bleak-house` =~ /no ruby-bleak-house in/
29
39
 
30
40
  Dir.chdir("ruby-1.8.6") do
31
41
 
32
- # Patch
42
+ # Patch, configure, and build
33
43
  system("patch -p0 < \'#{source_dir}/gc.c.patch\' > ../gc.c.patch.log 2>&1")
34
44
  system("patch -p0 < \'#{source_dir}/parse.y.patch\' > ../parse.y.patch.log 2>&1")
35
-
36
- # Configure
37
45
  system("./configure --prefix=#{binary_dir[0..-5]} > ../configure.log 2>&1") # --with-static-linked-ext
38
-
39
- # Make
40
46
  system("make > ../make.log 2>&1")
41
47
 
42
48
  binary = "#{binary_dir}/ruby-bleak-house"
@@ -44,7 +50,8 @@ if `which ruby-bleak-house` =~ /no ruby-bleak-house in/
44
50
  # Install binary
45
51
  if File.exist? "ruby"
46
52
  # Avoid "Text file busy" error
47
- exec("rm #{binary}; cp ./ruby #{binary}; chmod 755 #{binary}")
53
+ File.delete binary if File.exist? binary
54
+ exec("cp ./ruby #{binary}; chmod 755 #{binary}")
48
55
  else
49
56
  raise "Binary did not build"
50
57
  end
@@ -58,4 +65,4 @@ if `which ruby-bleak-house` =~ /no ruby-bleak-house in/
58
65
  # Success
59
66
  end
60
67
 
61
- end
68
+ end
@@ -23,6 +23,15 @@ module BleakHouse
23
23
  open(
24
24
  File.dirname(__FILE__) + '/../../../ext/bleak_house/logger/snapshot.h'
25
25
  ).read[/\{(.*?)\}/m, 1] + ']')
26
+
27
+ def self.backwards_detect(array)
28
+ i = array.size - 1
29
+ while i >= 0
30
+ item = array[i]
31
+ return item if yield(item)
32
+ i -= 1
33
+ end
34
+ end
26
35
 
27
36
  def self.calculate!(frame, index, total, obj_count = nil)
28
37
  bsize = frame['births'].size
@@ -70,8 +79,13 @@ module BleakHouse
70
79
  else
71
80
  # Rebuild frames
72
81
  total_frames = `grep '^-1' #{logfile} | wc`.to_i - 2
73
-
82
+
74
83
  puts "#{total_frames} frames"
84
+
85
+ if total_frames < INITIAL_SKIP * 3
86
+ puts "Not enough frames for accurate results. Please record at least #{INITIAL_SKIP * 3} frames."
87
+ exit!
88
+ end
75
89
 
76
90
  Ccsv.foreach(logfile) do |row|
77
91
 
@@ -121,7 +135,7 @@ module BleakHouse
121
135
  end
122
136
 
123
137
  frames = frames[0..-2]
124
- frames.last['objects'] = frames.last['objects'].to_a # Work around a Marshal bug
138
+ frames.last['objects'] = frames.last['objects'].to_a # Work around a Marshal bug x86-64
125
139
 
126
140
  # Cache the result
127
141
  File.open(cachefile, 'w') do |f|
@@ -130,14 +144,24 @@ module BleakHouse
130
144
 
131
145
  end
132
146
 
147
+ puts "\nRehashing."
148
+
133
149
  # Convert births back to hashes, necessary due to the Marshal workaround
134
150
  frames.each do |frame|
135
- frame['births'] = Hash[*frame['births'].flatten]
151
+ frame['births_hash'] = {}
152
+ frame['births'].each do |key, value|
153
+ frame['births_hash'][key] = value
154
+ end
155
+ frame.delete('births')
136
156
  end
157
+
158
+ # require 'ruby-debug'; Debugger.start
159
+ #
160
+ # debugger
137
161
 
138
162
  # See what objects are still laying around
139
163
  population = frames.last['objects'].reject do |key, value|
140
- frames.first['births'][key] == value
164
+ frames.first['births_hash'][key] == value
141
165
  end
142
166
 
143
167
  puts "\n#{frames.size - 1} full frames. Removing #{INITIAL_SKIP} frames from each end of the run to account for\nstartup overhead and GC lag."
@@ -146,7 +170,7 @@ module BleakHouse
146
170
  frames = frames[INITIAL_SKIP..-INITIAL_SKIP]
147
171
 
148
172
  total_births = frames.inject(0) do |births, frame|
149
- births + frame['births'].size
173
+ births + frame['births_hash'].size
150
174
  end
151
175
  total_deaths = frames.inject(0) do |deaths, frame|
152
176
  deaths + frame['deaths'].size
@@ -155,13 +179,16 @@ module BleakHouse
155
179
  puts "\n#{total_births} total births, #{total_deaths} total deaths, #{population.size} uncollected objects."
156
180
 
157
181
  leakers = {}
158
-
182
+
183
+ # debugger
184
+
159
185
  # Find the sources of the leftover objects in the final population
160
186
  population.each do |id, klass|
161
- leaker = frames.detect do |frame|
162
- frame['births'][id] == klass
187
+ leaker = backwards_detect(frames) do |frame|
188
+ frame['births_hash'][id] == klass
163
189
  end
164
190
  if leaker
191
+ # debugger
165
192
  tag = leaker['meta']['tag']
166
193
  klass = CLASS_KEYS[klass] if klass.is_a? Fixnum
167
194
  leakers[tag] ||= Hash.new(0)
@@ -211,9 +238,10 @@ module BleakHouse
211
238
  impacts.each do |tag, total|
212
239
  puts " #{format('%.4f', total).rjust(7)}: #{tag}"
213
240
  end
214
- end
215
-
216
- puts "\nDone"
241
+
242
+ puts "\nDone"
243
+
244
+ end
217
245
 
218
246
  end
219
247
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.6
3
3
  specification_version: 2
4
4
  name: bleak_house
5
5
  version: !ruby/object:Gem::Version
6
- version: "3.4"
7
- date: 2007-10-31 00:00:00 -04:00
6
+ version: "3.5"
7
+ date: 2007-11-14 00:00:00 -05:00
8
8
  summary: A library for finding memory leaks.
9
9
  require_paths:
10
10
  - lib
@@ -80,7 +80,6 @@ files:
80
80
  - lib/bleak_house.rb
81
81
  - LICENSE
82
82
  - LICENSE_BSD
83
- - LICENSE_RUBY
84
83
  - Manifest
85
84
  - Rakefile
86
85
  - README
metadata.gz.sig CHANGED
Binary file
data/LICENSE_RUBY DELETED
@@ -1,53 +0,0 @@
1
- $BK\%W%m%0%i%`$O%U%j!<%=%U%H%&%'%"$G$9!%(BGPL(the GNU General
2
- Public License)$B$^$?$O0J2<$K<($9>r7o$GK\%W%m%0%i%`$r:FG[I[$G(B
3
- $B$-$^$9!%(BGPL$B$K$D$$$F$O(BCOPYING.txt$B%U%!%$%k$r;2>H$7$F2<$5$$!%(B
4
-
5
- 1. $BJ#@=$O@)8B$J$/<+M3$G$9!%(B
6
-
7
- 2. $B0J2<$N>r7o$N$$$:$l$+$rK~$?$9;~$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