NetLogo/NW-Extension — pull request #124 by nicolaspayette (2014-07-04 01:45:28+00:00)
Title: AgentSetChangeSubscribers never get unsubscribed

The `unsubscribe()` method is still there, but as of f972dd819783b6074a2e780ee0eb60d889a4d68d, it is not called anymore.

Consequence: every time an old `GraphContext` that was using special agentsets (i.e, `turtles`, `links` and breed agentsets) is abandoned, it may leave behind a couple of subscribers that never get garbage collected. The `TreeAgentSet`s continue to push notifications to these phantom subscribers forever. It's unnoticeable in normal use but, when running BehaviorSpace experiments, the list of subscribers keeps growing indefinitely and the simulations slow to a crawl. I suppose a long running simulation with lots of graph context switches would have the same effect.

The good news is that the fix might be a simple matter of calling `unsubscribe()` in the right places. Those places are probably something like `GraphContext.verify`, `prim.SetContext` and `prim.WithContext`.

@qiemem, I don't have time to look deeper into this tonight, but I'll be happy to help out/discuss/review if needed.