Skip to content

Fix/container gc retention#9918

Open
edwardwkrohne wants to merge 3 commits into
marimo-team:mainfrom
edwardwkrohne:fix/container-gc-retention
Open

Fix/container gc retention#9918
edwardwkrohne wants to merge 3 commits into
marimo-team:mainfrom
edwardwkrohne:fix/container-gc-retention

Conversation

@edwardwkrohne

@edwardwkrohne edwardwkrohne commented Jun 18, 2026

Copy link
Copy Markdown

📝 Summary

Closes #9880

Widgets created as

get_state, set_state = mo.state(False)
wgt = mo.ui.checkbox(on_change=set_state).style()
wgt

would never fire their set_state methods. The issue is that style returns

    return Html(h.div(children=as_dom_node(item).text, style=style_str))

which drops the actual python object item, preventing the corresponding frontend ui object from actually interacting with the backend.

Now, style is a class that derives from a new class ContainerHtml, which explicitly contains strong references to a list of children to prevent them from being garbage collected. The offending code survives as

    def _build_text(self) -> str:
        return h.div(children=self._children[0].text, style=self._style_str)

which uses the explicitly stored child self._children[0] instead of a local. Similar treatment has been given to accordion, callout, carousel, tabs, and sidebar, all of which could potentially drop their children by converting to text and losing the original.

tabs was slightly different in that it was already a UIElement, which would have been incompatible with the implementation of the new ContainerHtml class, so it was modified to explicitly store its own children.

sidebar was reparented to ContainerHtml and stores its children that way.

_BlockWrapped was also reparented to ContainerHtml.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Review in cubic

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 18, 2026 4:00am

Request Review

@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@edwardwkrohne

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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

Successfully merging this pull request may close these issues.

Multiple instances of potential garbage collection of live widgets

1 participant