Is there a method for widgets to delete / self destruct?

If I have:

import panel as pn
pn.extension()

col = pn.Column()
card = pn.Card(pn.pane.Markdown("hello"))
col.append(card)

If I do col.pop(), will card be cleaned from memory?

Also, is there a method to do card.remove()?

Hi @ahuang11

Could you provide more information about what problem you are trying to solve?

I don’t understand why you are thinking about removing the card from memory. Whether it takes up memory or not will probably not matter to any one. I think :slight_smile:

I am trying to create a content stream / feed (think Instagram) as a Column of Cards, but if the user / admin doesn’t like the content, they can click a Remove button to remove it from the stream / feed. Right now I loop through all the Cards to find the proper ID to pop from column, but even then I wonder if it still persists in memory?

There is a “visible” property; if I set to False, I assume it still sticks to memory?

1 Like

I don’t know if they are removed. My guess is that they are if they are no longer referenced in Python. But I guess you could make some test example and actually test it. Maybe by code add and remove a lot of cards and try to monitor the memory consumption.

Would be interesting to see the results.