SamSaffron/MiniProfiler

Memory leak on JRuby

Closed this issue · 4 comments

JRuby application servers that can do hot redeploys will shut down the old JRuby runtime without exiting the process. In a few places, rack-mini-profiler creates threads that won't shut down until the process dies. Each of these threads will cause a stopped JRuby runtime to sit around in memory much longer than necessary (they appear to be weakrefs and as such, should eventually be GC'd).

Rack::MiniProfiler::FileStore
Rack::MiniProfiler::MemoryStore

are definitely problematic.

Rack::MiniProfiler may be problematic. This one create a thread that can be exited under certain circumstances. I'd have to trace through to see when that happens.

The simple fix is to flag the thread in an at_exit handler. I did this for another project:

https://github.com/wr0ngway/lumber/blob/a35520abace41a87b455b15398be630e7ef5b2da/lib/lumber/level_util.rb#L83

If you're open to a similar solution I can pull together a pull request.

Pull request totally welcome. Issue totally makes sense

any news on this, I would like to wrap it up

Sorry, I had gotten roped into a separate bug in JRuby that's since been resolved, but I forgot to revisit this. I'll try to get to it this weekend.

I re-opened the issue on the new project with a pull request:

MiniProfiler/rack-mini-profiler#42