# Tools for memory tracking

**URL:** <https://rubytalk.org/t/tools-for-memory-tracking/21327>\
**Category:** ruby-talk\
**Created:** [5 October 2005 06:11 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327 "2005-10-05T06:11:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Beguelin](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@Adam\_Beguelin](https://rubytalk.org/u/Adam_Beguelin)\
**Post date:** [5 October 2005 06:11 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/1 "2005-10-05T06:11:19Z")

</div>

Does anyone have suggestions for tools that might help tracking down memory  
leaks in ruby programs? I've done a bit of searching around and haven't  
found anything.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cheers,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adam

---

<div class="post-metadata">

**Author:** ![Sweet\_Thiruvonam](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@Sweet\_Thiruvonam](https://rubytalk.org/u/Sweet_Thiruvonam)\
**Post date:** [5 October 2005 07:06 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/2 "2005-10-05T07:06:52Z")

</div>

Hello,  
&nbsp;&nbsp;&nbsp;&nbsp;Happy Harmony is the fastest growing matrimonial portal for  
Indians.  
You can email and IM other members without paying anything on this  
site.  
The amazing thing is that this site is totally free. Absolutely free.  
Cannot believe? Then click on this link to visit and register Happy  
Harmony.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[http://www.happyharmony.com/?idAff=14](http://www.happyharmony.com/?idAff=14)  
Background check is the new facility they have added now. You can do a  
free  
background check including age, address, phone numbers, property  
owneship  
information etc of anybody in the US.

Regards,  
Resh

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [5 October 2005 07:41 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/3 "2005-10-05T07:41:48Z")

</div>

Adam Beguelin wrote:

> Does anyone have suggestions for tools that might help tracking down  
> memory leaks in ruby programs? I've done a bit of searching around  
> and haven't found anything.

I don't know about tools, too. But you can cook yourself something with  
ObjectSpace. With this at least you can determine object counts and see  
whether some class's counts grow beyond bounds.

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Stephen\_Kellett](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@Stephen\_Kellett](https://rubytalk.org/u/Stephen_Kellett)\
**Post date:** [5 October 2005 08:51 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/4 "2005-10-05T08:51:48Z")

</div>

If you are using Windows there is Ruby Memory Validator at [http://www.softwareverify.com](http://www.softwareverify.com)

No Web page to describe it, but you can join the beta here:

[http://www.softwareverify.com/beta.php?product=RMVB000](http://www.softwareverify.com/beta.php?product=RMVB000)

Stephen

> **···**
>
> In message \<20051005061118.F087834128@beryllium.ruby-lang.org\>, Adam Beguelin \<adam@truveo.com\> writes
> 
> > Does anyone have suggestions for tools that might help tracking down memory  
> > leaks in ruby programs? I've done a bit of searching around and haven't  
> > found anything.
> 
> --  
> Stephen Kellett  
> Object Media Limited [http://www.objmedia.demon.co.uk/software.html](http://www.objmedia.demon.co.uk/software.html)  
> Computer Consultancy, Software Development  
> Windows C++, Java, Assembler, Performance Analysis, Troubleshooting

---

<div class="post-metadata">

**Author:** ![Caleb\_Tennis](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Caleb\_Tennis](https://rubytalk.org/u/Caleb_Tennis)\
**Post date:** [5 October 2005 12:44 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/5 "2005-10-05T12:44:10Z")

</div>

On Linux you can use Valgrind (valgrind.kde.org).

Are you experiencing the leaks when using external libraries or just core  
Ruby?

Caleb

> **···**
>
> On Wednesday 05 October 2005 01:11 am, Adam Beguelin wrote:
> 
> > Does anyone have suggestions for tools that might help tracking down memory  
> > leaks in ruby programs? I've done a bit of searching around and haven't  
> > found anything.

---

<div class="post-metadata">

**Author:** ![11137](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@11137](https://rubytalk.org/u/11137)\
**Post date:** [5 October 2005 11:36 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/6 "2005-10-05T11:36:34Z")

</div>

the follow code is in the mkmf.rb:

\*def checking\_for(m)  
&nbsp;&nbsp;f = caller[0][/in `(.*)'$/, 1] and f \<\< ": " #` for vim  
&nbsp;&nbsp;m = "checking for #{m}... "  
&nbsp;&nbsp;message "%s", m  
&nbsp;&nbsp;a = r = nil  
&nbsp;&nbsp;Logging::postpone do  
&nbsp;&nbsp;&nbsp;&nbsp;r = yield  
&nbsp;&nbsp;&nbsp;&nbsp;a = r ? "yes\n" : "no\n"  
&nbsp;&nbsp;&nbsp;&nbsp;"#{f}#{m}-------------------- #{a}\n"  
&nbsp;&nbsp;end  
&nbsp;&nbsp;message(a)  
&nbsp;&nbsp;Logging::message "--------------------\n\n"  
&nbsp;&nbsp;r  
end

\*what meaning of the '\*f = caller[0][/in `(.*)'$/, 1] and f \<\< ": " #` for vim\*'?

pls!

> **···**
>
> \*

---

<div class="post-metadata">

**Author:** ![daz](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@daz](https://rubytalk.org/u/daz)\
**Post date:** [5 October 2005 14:21 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/7 "2005-10-05T14:21:52Z")

</div>

limux... wrote:

> the follow code is in the mkmf.rb:
> 
> \*def checking\_for(m)  
> &nbsp;&nbsp;f = caller[0][/in `(.*)'$/, 1] and f \<\< ": " #` for vim  
> &nbsp;&nbsp;m = "checking for #{m}... "  
> &nbsp;&nbsp;message "%s", m  
> &nbsp;&nbsp;a = r = nil  
> &nbsp;&nbsp;Logging::postpone do  
> &nbsp;&nbsp;&nbsp;&nbsp;r = yield  
> &nbsp;&nbsp;&nbsp;&nbsp;a = r ? "yes\n" : "no\n"  
> &nbsp;&nbsp;&nbsp;&nbsp;"#{f}#{m}-------------------- #{a}\n"  
> &nbsp;&nbsp;end  
> &nbsp;&nbsp;message(a)  
> &nbsp;&nbsp;Logging::message "--------------------\n\n"  
> &nbsp;&nbsp;r  
> end
> 
> \*what meaning of the '\*f = caller[0][/in `(.*)'$/, 1] and f \<\< ": " #` for vim\*'?

def metha  
methb  
end

def methb  
sep; p(( f = caller )) # Execution history (Array)  
sep; p(( f = caller[0] )) # Take the most recent entry

# Take the first group from a string match result (else nil) # See [1]  
sep; p(( f = caller[0][/in `(.\*)'$/, 1] ))

# If there was a match, append ': ' to it  
sep; p(( f = caller[0][/in `(.\*)'$/, 1] and f \<\< ": " ))

# The rest is a comment  
end

def sep; puts('-' \* 30) end

metha

##-\> ------------------------------  
##-\> ["C:/TEMP/rbB105.TMP:2:in `metha'", "C:/TEMP/rbB105.TMP:17"]  
##-\> ------------------------------  
##-\> "C:/TEMP/rbB105.TMP:2:in `metha'"  
##-\> ------------------------------  
##-\> "metha"  
##-\> ------------------------------  
##-\> "metha: "

[1] str[regexp, fixnum]  
&nbsp;&nbsp;&nbsp;&nbsp;[class String - RDoc Documentation](http://www.ruby-doc.org/core/classes/String.html#M001373)

daz

---

<div class="post-metadata">

**Author:** ![Austin\_Ziegler5](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/austin_ziegler5/32/1985_2.png) [@Austin\_Ziegler5](https://rubytalk.org/u/Austin_Ziegler5)\
**Post date:** [5 October 2005 14:22 UTC](https://rubytalk.org/t/tools-for-memory-tracking/21327/8 "2005-10-05T14:22:05Z")

</div>

See the documentation on Kernel#caller

-austin

> **···**
>
> On 10/5/05, 刘孟江 \<limux@126.com\> wrote:
> 
> > \*what meaning of the '\*f = caller[0][/in `(.*)'$/, 1] and f \<\< ": " #` for vim\*'?
> 
> --  
> Austin Ziegler \* halostatue@gmail.com  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Alternate: austin@halostatue.ca
