Threads & GC

A

Andreas Schwarz

Hello,

I'm really confused by the behaviour of the following code:

irb(main):038:0> Thread.start do
irb(main):039:1* Mysql.connect('localhost', 'test', '', 'test')
irb(main):040:1> end
=> #<Thread:0x401de1f4 dead>
irb(main):041:0> ObjectSpace.each_object(Mysql) do |o| puts o.id end
537850026
=> 1
irb(main):042:0> GC.start
=> nil
irb(main):043:0> ObjectSpace.each_object(Mysql) do |o| puts o.id end
537850026
=> 1

Why does the Mysql object still exist after GC.start?

Andreas
 
T

ts

A> irb(main):042:0> GC.start
^^
||

A> Why does the Mysql object still exist after GC.start?

because GC::start is run on line 42, and ruby don't like this


p.s.: :)))))



Guy Decoux
 
R

Robert Klemme

ts said:
A> irb(main):042:0> GC.start
^^
||

A> Why does the Mysql object still exist after GC.start?

because GC::start is run on line 42, and ruby don't like this


p.s.: :)))))

Dang! And I thought it was because Matz never singned a written treaty
that CG.start will collect all unemployed instances...

:)

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top