Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed #233

Open
dragonite00 opened this issue Aug 7, 2023 · 6 comments · May be fixed by #300
Labels
bug something broken P2 needed for current cycle

Comments

@dragonite00
Copy link

I have a checklist that updates the page with a different set of ag-grid depending on the selected option. I get the following error
image

@dragonite00 dragonite00 changed the title memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed. [BUG] memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed. Aug 7, 2023
@BSd3v
Copy link
Collaborator

BSd3v commented Aug 7, 2023

Hello @dragonite00,

Could you please provide a working example of how you encounter this issue?

@dragonite00
Copy link
Author

dragonite00 commented Aug 7, 2023

hey, thanks for the response!

The setup is basically, I have a (pseudocode) dbc.RadioItems(id="checklist", options={1:1, 2:2, 3:3})

@callback(
     Output(display_id, "children"),
     Input("checklist", "value")
)
def update_all_tables(value):
    if value == 1:
        return [ag.Grid(), ag.Grid(), ag.Grid()]
    elif value == 2:
        # different set
        return [ag.Grid(), ag.Grid(), ag.Grid()],
    ....

if I click between the checklist values too quickly (actually it takes ~2s to return the ag grids so I'm not even clicking that fast), then I get the aforementioned error. along with a An object was provided as `children` instead of a component, string, or number (or list of those).

@BSd3v
Copy link
Collaborator

BSd3v commented Aug 7, 2023

Hmm, interesting, have you tried using Patch with pre-existing grids?

In this style, I think you are encountering the issue because you are removing the grid before it can be fully spun up. We can take a look as see if there is something we can do to remove the events if the grid is removed before completely available.

Most api and columnApi functions will only occur after the grid is completely up, unless you are then trying to pass it data or columnDefs immediately...

You could also potentially use the new getApiAsync and getColumnApiAsync if you are trying to manipulate it.

@dragonite00
Copy link
Author

dragonite00 commented Aug 7, 2023

Hmm, interesting, have you tried using Patch with pre-existing grids?

hmm, if you mean have a fixed set of grids, it's not possible because the checklist also controls the number of grids

We can take a look as see if there is something we can do to remove the events if the grid is removed before completely available.

this would be amazing, since this pattern seems most "intuitive" to me

Most api and columnApi functions will only occur after the grid is completely up, unless you are then trying to pass it data or columnDefs immediately...

Hm, I thought passing columnDefs in the return ag.Grid is the standard practice (at least from https://dash.plotly.com/dash-ag-grid/getting-started). Do you mean I could avoid this issue if I return the ag grid object first, and then add a callback to pass coldefs later?
edit: I just tried not passing coldefs on initialization, I still run into the exact same error

@BSd3v
Copy link
Collaborator

BSd3v commented Aug 7, 2023

Can you please provide a working example of this?

I cannot dig into what is happening unless there is something to test with.

Are you also passing all the data and stuff to the grids too?

@BSd3v
Copy link
Collaborator

BSd3v commented Apr 9, 2024

Hello @dragonite00,

Could you give this a test on the v31 of the grid to see if this issue persists?

@gvwilson gvwilson assigned gvwilson and unassigned gvwilson Jul 27, 2024
@gvwilson gvwilson changed the title [BUG] memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed. memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed Aug 13, 2024
@gvwilson gvwilson added bug something broken P2 needed for current cycle labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants