Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I keep GenericTreeModel from leaking references?

leaking references
0
10 Posted

How do I keep GenericTreeModel from leaking references?

0

Arjan Molena added a”leak_references” property to GenericTreeModel to turn this behavior off, but in his words, “Turning this feature off (default is on, the old behaviour) will always decrement the refcount on PyObjects. This will prevent memory/refcnt leaks from happening. The Model should ensure that objects which are used as iterators are not destroyed before the iterator is destroyed. This sounds a bit silly, but there are no other way, unless we get to know when a iterator is being removed…” If you turn off “leak_references” and don’t keep careful track of your nodes, you get a good old-fashioned segfault. One easy way to “ensure that objects which are used as iterators are not destroyed before the iterator is destroyed” is to have your model keep a dictionary or list of tree nodes so that a reference stays around until you explicitly delete it. (See FAQ 13.15 for another method of keeping track of node references.

0

Arjan Molena added a”leak_references” property to GenericTreeModel to turn this behavior off, but in his words, “Turning this feature off (default is on, the old behaviour) will always decrement the refcount on PyObjects. This will prevent memory/refcnt leaks from happening. The Model should ensure that objects which are used as iterators are not destroyed before the iterator is destroyed. This sounds a bit silly, but there are no other way, unless we get to know when a iterator is being removed…” If you turn off “leak_references” and don’t keep careful track of your nodes, you get a good old-fashioned segfault. One easy way to “ensure that objects which are used as iterators are not destroyed before the iterator is destroyed” is to have your model keep a dictionary or list of tree nodes so that a reference stays around until you explicitly delete it.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.