# \[ANN\] dike-0.0.2 - a memory leak debugger for rails

**URL:** <https://www.ruby-forum.com/t/ann-dike-0-0-2-a-memory-leak-debugger-for-rails/115754>\
**Category:** Rails\
**Created:** [September 28, 2007, 6:48am UTC](https://www.ruby-forum.com/t/ann-dike-0-0-2-a-memory-leak-debugger-for-rails/115754 "2007-09-28T06:48:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ara.t.howard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a8b319/32.png) [@ara.t.howard](https://www.ruby-forum.com/u/ara.t.howard)\
**Post date:** [September 28, 2007, 6:48am UTC](https://www.ruby-forum.com/t/ann-dike-0-0-2-a-memory-leak-debugger-for-rails/115754/1 "2007-09-28T06:48:51Z")

</div>

NAME

dike

SYNOPSIS

a simple memory leak detector for ruby with preconfigured rails  
hooks.

INSTALL

gem install dike

URIS

[http://www.codeforpeople.com/lib/ruby/](http://www.codeforpeople.com/lib/ruby/)  
[http://rubyforge.org/projects/codeforpeople/](http://rubyforge.org/projects/codeforpeople/)

DESCRIPTION

the concept behind dike.rb is simple: class Object is extended in  
order that  
the location of each object’s creation is tracked. a summarizer  
command is  
given to walk ObjectSpace using each object’s class and the location  
if it’s  
creation to detect memory leaks. not all leaks can be detected and  
some that  
are may not really be leaks, but dike provided a simple way to see  
the  
hotspots in your code that may potentially be leaking.

EXAMPLES

PURE RUBY

```
require 'dike'

Dike.log STDERR # the default

Thread.new do
  sleep 4.2 and Dike.finger
end

Main.start

```

RAILS

```
file:RAILS_ROOT/config/environment.rb
  ...
  require 'dike'

shell: ./script/server

shell: curl --silent http://localhost:3000 >/dev/null

shell: cat ./log/dike/0
---
- class: String
  count: 90769
  trace: []
- class: Array
  count: 18931
  trace: []
- class: Class
  count: 2
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

```
shell: curl --silent http://localhost:3000 >/dev/null

shell: cat ./log/dike/1
---
- class: String
  count: 100769
  trace: []
- class: Array
  count: 19931
  trace: []
- class: Class
  count: 5
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

```
shell: dike ./log/dike
...
- class: Class
  count: 3
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

SUMMARY

- the ‘Dike.finger’ method dumps it’s log in a format showing

- loading into a rails environment causes snapshots of the above  
format to  
be dumped into RAILS\_ROOT/log/dike/ after each request. each  
snapshot is  
incrementally numbered 0, 1, …

- the ‘dike’ command line tool can be used in two ways

- options that affect logging

LIMITATIONS

not all object creation can be tracked and not all leaks are  
reported.

AUTHOR

ara [dot] t [dot] howard [at] gmail [dot] com

---

<div class="post-metadata">

**Author:** ![ara.t.howard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a8b319/32.png) [@ara.t.howard](https://www.ruby-forum.com/u/ara.t.howard)\
**Post date:** [September 28, 2007, 11:27am UTC](https://www.ruby-forum.com/t/ann-dike-0-0-2-a-memory-leak-debugger-for-rails/115754/2 "2007-09-28T11:27:55Z")

</div>

---------- Forwarded message ----------  
From: ara.t.howard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Date: 28 sept. 2007 06:48  
Subject: [Rails] [ANN] dike-0.0.2 - a memory leak debugger for rails  
To: “Ruby on Rails: Talk” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

NAME

dike

SYNOPSIS

a simple memory leak detector for ruby with preconfigured rails  
hooks.

INSTALL

gem install dike

URIS

[http://www.codeforpeople.com/lib/ruby/](http://www.codeforpeople.com/lib/ruby/)  
[http://rubyforge.org/projects/codeforpeople/](http://rubyforge.org/projects/codeforpeople/)

DESCRIPTION

the concept behind dike.rb is simple: class Object is extended in  
order that the location of each object’s creation is tracked. a  
summarizer command is given to walk ObjectSpace using each  
object’s class and the location if it’s creation to detect memory  
leaks. not all leaks can be detected and some that are may  
not really be leaks, but dike provided a simple way to see the  
hotspots in your code that may potentially be leaking.

EXAMPLES

PURE RUBY

```
require 'dike'

Dike.log STDERR # the default

Thread.new do
  sleep 4.2 and Dike.finger
end

Main.start

```

RAILS

```
file:RAILS_ROOT/config/environment.rb
  ...
  require 'dike'

shell: ./script/server

shell: curl --silent http://localhost:3000 >/dev/null

shell: cat ./log/dike/0
---
- class: String
  count: 90769
  trace: []
- class: Array
  count: 18931
  trace: []
- class: Class
  count: 2
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

```
shell: curl --silent http://localhost:3000 >/dev/null

shell: cat ./log/dike/1
---
- class: String
  count: 100769
  trace: []
- class: Array
  count: 19931
  trace: []
- class: Class
  count: 5
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

```
shell: dike ./log/dike
...
- class: Class
  count: 3
  trace:
  - /Users/ahoward/site/votelink.com/public/../config/../lib/

```

widgets.rb:222:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:220:in `each’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:220:in `class_factory' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:248:in `Widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets/page/base.rb:1  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:31:in `require' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:31:in `load’  
- /Users/ahoward/site/votelink.com/public/…/config/…/lib/  
widgets.rb:16:in `for_controller' - /Users/ahoward/site/votelink.com/public/../config/../lib/ widgets.rb:243:in `widget’  
- /Users/ahoward/site/votelink.com/public/…/config/…/app/  
controllers/application.rb:150  
…

SUMMARY

- the ‘Dike.finger’ method dumps it’s log in a format showing

- loading into a rails environment causes snapshots of the  
above format to be dumped into RAILS\_ROOT/log/dike/ after  
each request. each snapshot is incrementally numbered 0, 1, …

- the ‘dike’ command line tool can be used in two ways

- options that affect logging

LIMITATIONS

not all object creation can be tracked and not all leaks are  
reported.

AUTHOR

ara [dot] t [dot] howard [at] gmail [dot] com

–  
Ruby ( [http://www.rubyfrance.org](http://www.rubyfrance.org) ) on Rails ( [http://www.railsfrance.org](http://www.railsfrance.org)  
)

---

<div class="post-metadata">

**Author:** ![ara.t.howard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a8b319/32.png) [@ara.t.howard](https://www.ruby-forum.com/u/ara.t.howard)\
**Post date:** [September 28, 2007, 11:40am UTC](https://www.ruby-forum.com/t/ann-dike-0-0-2-a-memory-leak-debugger-for-rails/115754/3 "2007-09-28T11:40:46Z")

</div>

J’ai vu l’annonce sur la list. Mais tu l’as testé ?

–  
Cyril M.

> **[Shingara - Actualité et News](https://www.shingara.fr/)**
>
> Actualité et News
