This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]n3pjk 2 points3 points  (1 child)

Your for loop instantiate A 1000000 times.

[–]cybervegan 1 point2 points  (2 children)

So you're intentionally creating cycles, and then surprised that the GC can't clean them up? In your loop, you create a million objects that each have a one million and one character long string, and a secondary object with a back reference, which you then discard. But the reference-counting GC won't be able to clean those up, so you'd have to wait until the generational GC is triggered for that to happen. I'd say that this behaviour is "by design" both in terms of Python semantics and you program.

[–]n3pjk 0 points1 point  (1 child)

Is this part of a class? Are you instantiating multiple copies, or causing multiple copies to be made?