HeadlessChildModel instances not being disposed of and headless model viewer displaying wrong child model
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 20
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Mostly opening this to document a weird state I've arrived in. I don't have repro steps, but will update if I can figure them out. If I had to guess at repro steps, it would be something like:
- Run a model with a headless child model.
ls:show 0to view the world state.- With that open, edit the code of the child model (opened with the LevelSpace menu)
- Maybe something like do
ls:resetand rerun model with the viewer still open? Basically, having a bunch of ways of having the child model be referenced and then doing things that might change one reference but not the others.
I arrived at a state where an instance of a headless child model being used by the model and the one displayed with ls:show are different. The child model's command center seemed to talk to the same instance that the model used, as can be seen here:

Note that the world size seen in the view is the world size the child model has on initial load, but then it changes when run.
Looking at a heap dump, we see that there are, in fact, 6 instance of HeadlessChildModel:

HeadlessChildModel#5 appears to be the one used by the model and the command center, as indicated by the number of turtles in its world (the command center indicated 11 turtles, as did running [ count turtles ] ls:of 0 in the parent model):

HeadlessChildModel#6 appears to be used by the backing model manager:

but also seems to have agents in it:

I haven't been able to figure out which headless model is the one actually being displayed by the model viewer, but the heapdump is attached.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining HeadlessChildModel references around the backing model manager, model viewer, and the ls:show and ls:reset flows described in the issue. Use the attached heap dump and the listed sequence as investigation inputs; done means the duplicate instances are understood and the viewer and running model consistently reference the intended child model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100