Hunting down memory leaks in Ruby

Preview:

Citation preview

Hunting down memory leaks

Sergey Alekseev

Hunting down memory leaks

Sergey Alekseev

What’s a memory leak?

Bloat vs. Leak

Get rid of a memory bloat first

*disable NewRelic developer_modein staging

How to hunt down a leak?

1) Find

2) Destroy

How to find a leak?

First look into https://github.com/ASoftCo/leaky-

gems

The most effective way

Siege + New Relic + Skylight

/action-1 /action-2

New Relic – Transactions

• Most time consuming

• Slowest average response time

• Apdex most dissatisfying

• …

2 types: Ruby & C memory leaks

Ruby memory leaks

• Errno::ENOMEM

• GC.start

• ObjectSpace.count_objects

• ObjectSpace.each_object(String)

• GC.stat

C memory leaks

• Valgrind

• https://lbtwiki.cern.ch/bin/view/Online/Kcachegrind

• Heap dump

Сергей АлексеевRuby developer, Founder @ ASoft.co

• https://github.com/sergey-alekseev

• info @ asoft.co

• http://sergeyalekseev.by/#contacts

Recommended