Reflection/Metadata copy, tracking a possible memleak ? #13458
Replies: 2 comments 2 replies
|
I think what you're looking at is the script holding those tables, not SQLAlchemy.
Your own output actually shows this. I ran your scenario 4 both ways on 2.0.51: Same for the event registry. It sits at exactly 3 across 30+ cycles here. Those three are module-level DDL listeners registered once at import ( One thing worth ruling out explicitly, since it's the obvious suspect: walking the referrers, the chain does pass through On method: Which brings up the part I can't answer from here — this repro doesn't show a SQLAlchemy leak, so whatever is growing in your real application is somewhere else. If you re-instrument with the cycle wrapped in a function and it still climbs, that result would be a lot more informative than this one, and worth posting. What version are you on, out of curiosity? I used 2.0.51. I noticed 2.1 betas going around and reflection did change there, so if you're on 2.1 it'd be worth me re-checking. |
|
Thanks for taking the time but in fact I closed the discussion as I noticed, as you did quickly, that I had to scope the various tests to be accurate in the analysis. I have still an issue in my main application, and narrowing it down slowly so I will reopen the discussion if something raises up. Thanks again for the explanation ! I'm on SQLAlchemy 2.0.48, using declarative mixins and mixed with geoalchemy2 which register events as well, so its quite entangled as we try to redeclare a new declarative hierarchy on new engine creation (targeted databases may differ). |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
In our application we implement the following:
to_metadatatable), a new db is created with the use of a local second engine (PostgreSQL as well) and themetadata.create_allmethod, and the data copied through a loop of select to insert statements between both dbsI'm trying to add instrumentation to track the problem and I'm seeing Tables objects related to metadata I'm trying to clean up surviving, as well as the sqlalchemy event registry growing.
I'm "reproducing" (in quotes because I'm not sure If what I'm looking at is accurate) with the following example, using sqlite to stay local:
A sample output:
I'm trying to understand where those tables references are held, and if they should still be there or not, etc ...
Thank you for your time
All reactions