Hello,
I am debugging a memory leak issue after the restart of my rails
application
in tomcat. I am using tomcat manager to stop and start the application.
Memory usage goes up after every restart and it becomes unusable after
few
restarts. It is the only ruby/rails application that is deployed in
tomcat.
When I used jstack to list java threads, I noticed that there are many
jruby
threads running even after the application has been stopped. Number of
threads keeps growing after each restart.
I did try the following code to kill the threads:
at_exit do
Thread.list.each { |t| Rails.logger.warn { “Thread Status is:
#{t.inspect}, #{t[:name]}, #{t.status}” } }
Thread.list.each { |t| t.exit unless t == Thread.current }
Rails.logger.warn { “EXITING**” }
end
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x99dde9sleep, synchronize_users, sleep
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x1b80d21sleep, owner_audit, sleep
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x660d14run, , run
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x1e4c027run, , run
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x1036c7fsleep, , sleep
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0x1c814basleep, flow_audit, sleep
2010-07-27 17:46:41,531 WARN ( ?:?) - Thread Status is:
#Thread:0xc8e634run, , run
2010-07-27 17:46:41,546 WARN ( ?:?) -
EXITING**
However, I still see lots of jruby threads in tomcat after stopping the
application and memory issue.
Here is my environment:
OS: Windows 2003
Jruby: 1.5.0
Tomcat: 6.0.18
Any idea how to resolve this issue?
Thanks,
-Rakesh