bleak_house 4.5 → 4.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ v4.6. Allow snapshotting without running the GC first.
3
+
2
4
  v4.5. Enable SET_CURRENT_SOURCE() for better reporting (tmm1, joedamato).
3
5
 
4
6
  v4.4. Switch to Ruby 1.8.7p174.
data/bleak_house.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{bleak_house}
5
- s.version = "4.5"
5
+ s.version = "4.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Weaver"]
9
9
  s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
- s.date = %q{2009-09-02}
10
+ s.date = %q{2009-10-02}
11
11
  s.default_executable = %q{bleak}
12
12
  s.description = %q{A library for finding memory leaks.}
13
13
  s.email = %q{}
data/ext/snapshot.c CHANGED
@@ -14,9 +14,10 @@ static VALUE heaps_length(VALUE self) {
14
14
  return INT2FIX(rb_gc_heaps_length());
15
15
  }
16
16
 
17
- /* Walk the live, instrumented objects on the heap and write them to <tt>_logfile</tt>. */
18
- static VALUE snapshot(VALUE self, VALUE _logfile) {
17
+ /* Inner method; call BleakHouse.snapshot instead. */
18
+ static VALUE ext_snapshot(VALUE self, VALUE _logfile, VALUE _gc_runs) {
19
19
  Check_Type(_logfile, T_STRING);
20
+ Check_Type(_gc_runs, T_FIXNUM);
20
21
 
21
22
  RVALUE *obj, *obj_end;
22
23
  st_table_entry *sym;
@@ -40,7 +41,7 @@ static VALUE snapshot(VALUE self, VALUE _logfile) {
40
41
  int i;
41
42
  char * chr;
42
43
 
43
- for (i = 0; i < 3; i++) {
44
+ for (i = 0; i < FIX2INT(_gc_runs); i++) {
44
45
  /* request GC run */
45
46
  rb_funcall(rb_mGC, rb_intern("start"), 0);
46
47
  rb_thread_schedule();
@@ -144,7 +145,7 @@ void
144
145
  Init_snapshot()
145
146
  {
146
147
  rb_mB = rb_define_module("BleakHouse");
147
- rb_define_singleton_method(rb_mB, "snapshot", snapshot, 1);
148
+ rb_define_singleton_method(rb_mB, "ext_snapshot", ext_snapshot, 2);
148
149
  rb_define_singleton_method(rb_mB, "heaps_used", heaps_used, 0);
149
150
  rb_define_singleton_method(rb_mB, "heaps_length", heaps_length, 0);
150
151
  }
data/lib/bleak_house.rb CHANGED
@@ -6,3 +6,17 @@ end
6
6
  RUBY_VERSION = `ruby -v`.split(" ")[1]
7
7
  require 'snapshot'
8
8
  require 'bleak_house/hook'
9
+
10
+ class << BleakHouse
11
+ private :ext_snapshot
12
+ end
13
+
14
+ module BleakHouse
15
+
16
+ # Walk the live, instrumented objects on the heap and write them to
17
+ # <tt>logfile</tt>. Accepts an optional number of GC runs to perform
18
+ # before dumping the heap.
19
+ def self.snapshot(logfile, gc_runs = 3)
20
+ ext_snapshot(logfile, gc_runs)
21
+ end
22
+ end
@@ -18,13 +18,19 @@ class BleakHouseTest < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_snapshot
21
- symbol_count = Symbol.all_symbols.size
22
21
  BleakHouse.snapshot(FILE)
23
22
  assert File.exist?(FILE)
24
23
  assert BleakHouse.heaps_used > 0
25
24
  assert BleakHouse.heaps_length > 0
26
25
  end
27
26
 
27
+ def test_snapshot_gc_runs
28
+ BleakHouse.snapshot(FILE, 0)
29
+ assert File.exist?(FILE)
30
+ assert BleakHouse.heaps_used > 0
31
+ assert BleakHouse.heaps_length > 0
32
+ end
33
+
28
34
  def test_exception
29
35
  assert_raises(RuntimeError) do
30
36
  BleakHouse.snapshot("/")
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bleak_house
3
3
  version: !ruby/object:Gem::Version
4
- version: "4.5"
4
+ version: "4.6"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Weaver
@@ -30,7 +30,7 @@ cert_chain:
30
30
  yZ0=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-09-02 00:00:00 -07:00
33
+ date: 2009-10-02 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
metadata.gz.sig CHANGED
Binary file