# Difficulty in understanding the valgrind output for ror app

**URL:** <https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563>\
**Category:** Rails\
**Created:** [November 5, 2008, 7:09am UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563 "2008-11-05T07:09:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 5, 2008, 7:09am UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563/1 "2008-11-05T07:09:26Z")

</div>

Hi,  
I am facing the difficulty in understanding the output of valgrind  
memory leaks. How to interpret it. pls help me out.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 5, 2008, 3:38pm UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563/2 "2008-11-05T15:38:55Z")

</div>

On Nov 5, 1:09 am, Santosh T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,  
> I am facing the difficulty in understanding the output of valgrind  
> memory leaks. How to interpret it. pls help me out.

For the ruby interpreter, you should probably think about running  
valgrind with the following options:

–partial-loads-ok=yes --undef-value-errors=no

However, you probably shouldn’t be using valgrind to try to debug  
memory leaks in Ruby or Rails – valgrind is going to see memory  
malloc()ed by the Ruby interpreter for fast object allocation as a  
leak, which it isn’t. Plus, valgrind is going to tell you where in the  
C code (ruby interpreter source code) the leak “appears” to come from  
– which is totally useless for what you’re probably trying to do.

I recommend using Bleak House instead to track down Ruby and Rails  
memory leaks:

[http://blog.evanweaver.com/files/doc/fauna/bleak\_house/files/README.html](http://blog.evanweaver.com/files/doc/fauna/bleak_house/files/README.html)

Good luck.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 6, 2008, 5:23am UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563/3 "2008-11-06T05:23:23Z")

</div>

Thank You for information.I ll try with bleak\_house.

I recommend using Bleak House instead to track down Ruby and Rails  
memory leaks:

[http://blog.evanweaver.com/files/doc/fauna/bleak\_house/files/README.html](http://blog.evanweaver.com/files/doc/fauna/bleak_house/files/README.html)

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 6, 2008, 6:33am UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563/4 "2008-11-06T06:33:21Z")

</div>

Hi, I am trying with bleak\_house… it gives the dump… but in dump  
analyze I am getting the following output…I am not able to track this  
output also…pls help me out.

bleak /tmp/bleak.6524.0.dump  
Displaying top 20 most common line/class pairs  
456423 total objects  
456423 filled heap slots  
296358 free heap slots  
408091 **null** : **null** : **node**  
37164 **null** : **null** :String  
2983 **null** : **null** :Class  
1505 **null** : **null** :Array  
1399 **null** : **null** :Regexp  
1107 **null** : **null** :Proc  
809 **null** : **null** :Hash  
585 **null** : **null** : **varmap**  
515 **null** : **null** :Module  
259 **null** : **null** : **scope**  
171 **null** : **null** :ActiveRecord::ConnectionAdapters::MysqlColumn  
167 **null** : **null** :Range  
167 **null** : **null** :ActionController::Routing::DividerSegment  
86 **null** : **null** :Float  
85 **null** : **null** :SOAP  
74 **null** : **null** :ActionController::Routing::StaticSegment  
73 **null** : **null** :XSD::QName  
62 **null** : **null** 💎:Requirement  
54 **null** : **null** 💎:Version  
54 **null** : **null** :ActiveRecord::Reflection::AssociationReflection

> However, you probably shouldn’t be using valgrind to try to debug  
> memory leaks in Ruby or Rails – valgrind is going to see memory  
> malloc()ed by the Ruby interpreter for fast object allocation as a  
> leak, which it isn’t. Plus, valgrind is going to tell you where in the  
> C code (ruby interpreter source code) the leak “appears” to come from  
> – which is totally useless for what you’re probably trying to do.
> 
> I recommend using Bleak House instead to track down Ruby and Rails  
> memory leaks:
> 
> [http://blog.evanweaver.com/files/doc/fauna/bleak\_house/files/README.html](http://blog.evanweaver.com/files/doc/fauna/bleak_house/files/README.html)
> 
> Good luck.

---

<div class="post-metadata">

**Author:** ![santoshturamari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@santoshturamari](https://www.ruby-forum.com/u/santoshturamari)\
**Post date:** [November 6, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/difficulty-in-understanding-the-valgrind-output-for-ror-app/152563/5 "2008-11-06T17:55:22Z")

</div>

On Nov 6, 12:33 am, Santosh T. \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> Hi, I am trying with bleak\_house… it gives the dump… but in dump  
> analyze I am getting the following output…I am not able to track this  
> output also…pls help me out.
> 
> bleak /tmp/bleak.6524.0.dump  
> Displaying top 20 most common line/class pairs  
> 456423 total objects  
> 456423 filled heap slots  
> 296358 free heap slots  
> 408091 **null** : **null** : **node**

Are you using eval() quite often in your code? That’s a big number.  
From the Bleak House documentation:

 It is normal to see lots of null:null references, especially for nodes. Using eval() too much can be a cause of node leaks. You can track eval() by using sourceline macros in your code:

```
 eval("CODE", nil, __FILE__ , __LINE__ )

```

> 167 **null** : **null** :Range  
> 167 **null** : **null** :ActionController::Routing::DividerSegment  
> 86 **null** : **null** :Float  
> 85 **null** : **null** :SOAP  
> 74 **null** : **null** :ActionController::Routing::StaticSegment  
> 73 **null** : **null** :XSD::QName  
> 62 **null** : **null** 💎:Requirement  
> 54 **null** : **null** 💎:Version  
> 54 **null** : **null** :ActiveRecord::Reflection::AssociationReflection

The rest of these counts look reasonable to me. For example, running  
bleak house on an empty script that only requires rubygems and  
bleak\_house has, as its top output:

31778 **null** : **null** : **node**  
23729 **null** : **null** :String  
1945 **null** : **null** :Array

Without knowing more about your app (Rails server? Standalone script?  
Daemon?) I can’t direct you more specifically – but if you’re using  
eval() (or a related function) then that’s where I’d start. If you’re  
not using eval, then you may want to make sure you’re reproducing the  
leak while running in bleak house.
