Background
This was identified during a ChatGPT-assisted review of #1835.
Interactive rich outputs retain R-side viewer state in .sess_env$dataviews so that notebook cells can continue paging or opening their full Data/List Viewer without serializing the complete object.
However, these states do not appear to be released when the corresponding Interactive output is no longer live.
For example, #1835 stores each plain list result with:
dataview_set_state(view_id, root)
and Interactive table outputs similarly retain Data Viewer state. Once an Interactive generation becomes archived, the extension correctly disables live controls, but the corresponding R-side state may remain referenced until the runtime itself is stopped.
This means old Interactive outputs can keep potentially large R objects alive even though they can no longer be browsed live.
Possible direction
Consider managing these states as Interactive-owned viewer resources, and dispose them when they can no longer be used, for example when:
- an Interactive generation is replaced or restarted;
- retained history is evicted;
- an Interactive session/output is otherwise permanently discarded.
This should probably cover both existing table outputs and the list outputs introduced in #1835 rather than adding list-specific cleanup.
The existing state_generation / dataview_dispose mechanism from #1741 may provide the appropriate foundation, but Interactive output retention and reconnect semantics need to be taken into account.
Background
This was identified during a ChatGPT-assisted review of #1835.
Interactive rich outputs retain R-side viewer state in
.sess_env$dataviewsso that notebook cells can continue paging or opening their full Data/List Viewer without serializing the complete object.However, these states do not appear to be released when the corresponding Interactive output is no longer live.
For example, #1835 stores each plain list result with:
and Interactive table outputs similarly retain Data Viewer state. Once an Interactive generation becomes archived, the extension correctly disables live controls, but the corresponding R-side state may remain referenced until the runtime itself is stopped.
This means old Interactive outputs can keep potentially large R objects alive even though they can no longer be browsed live.
Possible direction
Consider managing these states as Interactive-owned viewer resources, and dispose them when they can no longer be used, for example when:
This should probably cover both existing table outputs and the list outputs introduced in #1835 rather than adding list-specific cleanup.
The existing
state_generation/dataview_disposemechanism from #1741 may provide the appropriate foundation, but Interactive output retention and reconnect semantics need to be taken into account.