Resolv.rb memory usage / core dumps


(Brad Hilton) #1

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


(Nobuyoshi Nakada) #2

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