Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actors are not released by GC after proper termination #495

Closed
niamster opened this issue Feb 21, 2015 · 7 comments
Closed

Actors are not released by GC after proper termination #495

niamster opened this issue Feb 21, 2015 · 7 comments
Milestone

Comments

@niamster
Copy link
Contributor

After calling actor.terminate the actual actor instance(and all the proxies, cells, etc) are still floating even after explicit call to ruby GC.
I've tried to find all the references and clean up manually but it still was not sufficient.
Obviously I'm missing smth. After few tricks, ruby-mass did not show any references to the actor instance(which is CellProxy instance) though the instance was still floating(seen in Mass.index Test).
Probably that is because of some Celluloid tricks caused a circular dependency somewhere ...

To ensure that the instance is GC'ed I've added following finalizer:

class Test
  include Celluloid
  def initialize
    ObjectSpace.define_finalizer(self, self.class.finalize)
  end
  def self.finalize
    proc { p "Bang!" }
  end
end
Test.new.terminate

This is a problem for a long running server apps(DCell for example).

Configuration: celluloid v0.16, ruby 2.2.0, x86-64 linux

@tarcieri
Copy link
Member

Can you post a reproduction of the problem? There are clearly a number of long-running Celluloid programs that don't have this problem

@niamster
Copy link
Contributor Author

Here's a test case: https://gist.github.com/niamster/9f8dc8fb510164fbbc9c
If celluloid is not included(just commenting the "require") the instance is eventually properly removed by GC.

@tarcieri
Copy link
Member

Looks like you're right. I have absolutely no idea what could be holding a reference. I looked through the entire thread pool and there's nothing holding a reference in a thread local.

@niamster
Copy link
Contributor Author

It looks like there's a circular reference. Though I could not find it yet =/

@tarcieri
Copy link
Member

A circular reference should be handled properly by a mark/sweep GC

@niamster
Copy link
Contributor Author

Yes, you are right. I've did a simple test and class instance is properly removed by GC whether it has instance variable that holds reference to self whether it has variable of class instance that holds reference to "self".

@niamster
Copy link
Contributor Author

In fact it has the same root cause as #463 and is the latter has more activity I'm closing this issue as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants