Skip to content
Ian Denhardt edited this page Jan 28, 2022 · 8 revisions

Rules for Ref Counting

  1. By default, the caller is responsible for calling Release() on a capability when finished.
  2. Calling foo.Bar(baz) where foo and baz are capabilities transfers ownership of foo to baz. The foo instance will call bar.Release() when finished.
  3. Capabilities received as arguments to an RPC handler are borrowed and will be released when the RPC handler returns. Calling AddRef() returns a capability that persists beyond the scope of the RPC handler, at which point Rule 1 applies.

Special Cases

  1. [ BUG ] Passing the last reference for a capability to itself causes a deadlock.