Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
for more information, see https://pre-commit.ci
|
@dmadisetti this seems over-engineered? If there is a leak, it might be because if this reference cycle: https://github.com/marimo-team/marimo/blob/main/marimo/_ast/app.py#L621-L626 The |
|
@dmadisetti I looked at your commit and I don't understand. EDIT: marimo pair brought me up to speed, this is more involved than I thought. https://molab.marimo.io/notebooks/nb_ULHALbwMsQzjB24qU1bCaC |
|
Hmm. Not sure how we can fix #9198 while retaining Python semantics ... I think your first commit might have unintended side-effects, clearing globals when objects (such as values pulled out of the returned |
Absolutely agree. The follow-up fix cleans up everything it can (if
It seems to me, we always want the full notebook to run (it may have side effects etc). Retaining all variables also make sense since we don't know what the user will want. But curious if you have other ideas around this? |
My concern is that it feels like there would be many edge cases that could get confusing, for example if user code mutated things in ways that was not trackable by static analysis / required refs. So I'm not sure if this can be done 100% correctly. I was thinking we might just recommend to users that if they want reusability while controlling memory consumption, they opt for reusable functions instead of |
Hmm the only edgecase I can think of is |
📝 Summary
Closes #9198
Since module scopes are persistent, the continual use of
app.run()progressively fills up memory even after user accessible variables are not longer present. This PR introduces reference tracking on the_Namespacemapping class which clears the module dictionary on cleanup.cc @VishakBaddur: I just saw your comments on the initial issue. Good job on determining the root cause, but I think context manager is unneeded. The reference tracking here should silently cleanup without explicit management from the user.