Module: Memtf

Defined in:
lib/memtf.rb,
lib/memtf/version.rb

Overview

A simple utility to help isolate memory leaks. Two memory snapshots are compared to determine which classes, if any, are leaking.

Defined Under Namespace

Modules: Utilities Classes: Analyzer, Persistance, Reporter, Runner

Constant Summary collapse

START =

Represents the starting memory snapshot

:start
STOP =

Represents the ending memory snapshot

:stop
VERSION =

nodoc

"0.0.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.runnerObject

Returns the value of attribute runner.



11
12
13
# File 'lib/memtf.rb', line 11

def runner
  @runner
end

Class Method Details

.around(options = {}, &block) ⇒ Object

Generate an initial memory snapshot, execute the block, then generate the final memory snapshot.

Parameters:

  • options (Hash) (defaults to: {})


35
36
37
38
39
# File 'lib/memtf.rb', line 35

def around(options={}, &block)
  start(options)
  block.call if block_given?
  stop(options)
end

.start(options = {}) ⇒ Runner

Generate an initial memory snapshot.

Parameters:

  • options (Hash) (defaults to: {})

Returns:



17
18
19
# File 'lib/memtf.rb', line 17

def start(options={})
  self.runner = Runner.run(START, options)
end

.stop(options = {}) ⇒ Object

Generate a final memory snapshot.

Parameters:

  • options (Hash) (defaults to: {})


24
25
26
27
28
29
# File 'lib/memtf.rb', line 24

def stop(options={})
  default_group = self.runner.group
  Runner.run(STOP, {:group => default_group}.merge(options))
ensure
  self.runner = nil
end