# Resolv.rb memory usage / core dumps

**URL:** <https://rubytalk.org/t/resolv-rb-memory-usage-core-dumps/339>\
**Category:** ruby-talk\
**Created:** [20 June 2002 22:37 UTC](https://rubytalk.org/t/resolv-rb-memory-usage-core-dumps/339 "2002-06-20T22:37:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_Hilton](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Brad\_Hilton](https://rubytalk.org/u/Brad_Hilton)\
**Post date:** [20 June 2002 22:37 UTC](https://rubytalk.org/t/resolv-rb-memory-usage-core-dumps/339/1 "2002-06-20T22:37:47Z")

</div>

Hello,

In using resolv.rb (ruby 1.6.7) to do name lookups, I noticed that the  
classes UnconnectedUDP and ConnectedUDP create a new thread in  
ititialize(). They don’t attempt to clean up the thread (or join() it),  
however, so the following script eats up lots of memory and eventually  
stalls:

> **···**
>
> * * *
> 
> ## require 'resolv’ loop { Resolv::DNS::Requester::UnconnectedUDP.new }
> 
> Is this behavior intended, or should these objects kill/join their  
> internal Thread objects?
> 
> I also noticed something strange. If I modify resolv.rb slightly to  
> allow me to kill and join the threads, I get a core dump. For example,  
> I added:
> 
> def cleanup  
> @thread.exit  
> @thread.join  
> end
> 
> to the UnconnectedUDP class and changed my script above to say:
> 
> * * *
> 
> ## loop { Resolv::DNS::Requester::UnconnectedUDP.new.cleanup }
> 
> after a few hundred objects get created, the script core dumps.
> 
> Can anyone offer some help here?
> 
> Please CC me as I’m not on the list.
> 
> Thanks,  
> -Brad

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nobuyoshi\_Nakada](https://rubytalk.org/u/Nobuyoshi_Nakada)\
**Post date:** [21 June 2002 03:15 UTC](https://rubytalk.org/t/resolv-rb-memory-usage-core-dumps/339/2 "2002-06-21T03:15:39Z")

</div>

Hi,

> In using resolv.rb (ruby 1.6.7) to do name lookups, I noticed that the  
> classes UnconnectedUDP and ConnectedUDP create a new thread in  
> ititialize(). They don’t attempt to clean up the thread (or join() it),  
> however, so the following script eats up lots of memory and eventually  
> stalls:

Refer the thread from [ruby-talk:38525].

> * * *
> 
> ## loop { Resolv::DNS::Requester::UnconnectedUDP.new.cleanup }
> 
> after a few hundred objects get created, the script core dumps.

I couldn’t reproduce it in 100,000 iterations, with latest  
1.6.7 and CVS head.

> **···**
>
> At Fri, 21 Jun 2002 07:37:47 +0900, Brad Hilton wrote:
> 
> –  
> Nobu Nakada
