Question about garbage collection

Frank Millman frank at chagford.com
Tue Jan 16 09:43:38 EST 2024


On 2024-01-16 2:15 PM, Chris Angelico via Python-list wrote:
> 
> Where do you tend to "leave a reference dangling somewhere"? How is
> this occurring? Is it a result of an incomplete transaction (like an
> HTTP request that never finishes), or a regular part of the operation
> of the server?
> 

I have a class that represents a database table, and another class that 
represents a database column. There is a one-to-many relationship and 
they maintain references to each other.

In another part of the app, there is a class that represents a form, and 
another class that represents the gui elements on the form. Again there 
is a one-to-many relationship.

A gui element that represents a piece of data has to maintain a link to 
its database column object. There can be a many-to-one relationship, as 
there could be more than one gui element referring to the same column.

There are added complications which I won't go into here. The bottom 
line is that on some occasions a form which has been closed does not get 
gc'd.

I have been trying to reproduce the problem in my toy app, but I cannot 
get it to fail. There is a clue there! I think I have just 
over-complicated things.

I will start with a fresh approach tomorrow. If you don't hear from me 
again, you will know that I have solved it!

Thanks for the input, it definitely helped.

Frank




More information about the Python-list mailing list