Module: BleakHouse
This class performs the actual object logging of BleakHouse. To use it directly, you need to make calls to BleakHouse.snapshot.
By default, BleakHouse records a snapshot on exit. You can disable this by setting the environment variable NO_EXIT_HANDLER before startup.
It is also possible to externally trigger the snapshot at any time by sending SIGUSR2 to the process.
Example
At the start of your app, put:
require 'rubygems' require 'bleak_house' $logfile = "/path/to/logfile"
Run your app. Once it exits, analyze your data:
bleak /path/to/logfile
Child modules and classes
Module BleakHouse::Analyzer
Public Class Methods
ext_snapshot (p1, p2)
Inner method; call BleakHouse.snapshot instead.
/* Inner method; call BleakHouse.snapshot instead. */
static VALUE ext_snapshot(VALUE self, VALUE _logfile, VALUE _gc_runs) {
heaps_length ()
Number of allocated heaps_slots
/* Number of allocated <tt>heaps_slots</tt> */
static VALUE heaps_length(VALUE self) {
heaps_used ()
Number of filled heaps_slots
/* Number of filled <tt>heaps_slots</tt> */
static VALUE heaps_used(VALUE self) {
hook (gc_runs = 3)
The body of the exit handler and SIGUSR2 trap. It writes a snapshot to a dumpfile named after the current Process.pid.
# File lib/bleak_house/hook.rb, line 4 4: def self.hook(gc_runs = 3) 5: @count ||= 0 6: filename = "/tmp/bleak.%s.%03i.dump" % [Process.pid,@count] 7: STDERR.puts "** BleakHouse: working..." 8: BleakHouse.snapshot(filename, gc_runs) 9: STDERR.puts "** BleakHouse: complete\n** Bleakhouse: Run 'bleak #{filename}' to analyze." 10: @count += 1 11: end
snapshot (logfile, gc_runs = 3)
Walk the live, instrumented objects on the heap and write them to logfile. Accepts an optional number of GC runs to perform before dumping the heap.
# File lib/bleak_house.rb, line 19 19: def self.snapshot(logfile, gc_runs = 3) 20: ext_snapshot(logfile, gc_runs) 21: end