1

in the topic, Python variable declaration, @Karl Knechtel explained very well, but I have a doubt that how the unused value objects are getting handled in python. because throught the time whenever I do

id("Any value object which was refered before by a name")

this will still give me the same id at which the value object was stored at the first place in the RAM. Now if my code is very large and I have some many value objects which I am not using furthermore, these redundant value objects are still using my RAM, right? And how Python handles it?

Shubham srivastava
  • 227
  • 1
  • 4
  • 12
  • 5
    That's too vague. Objects are deleted when they go out of scope; if your "very large code" is all one scope, then you're doing something wrong in more ways than just memory management. – Daniel Roseman Aug 11 '17 at 10:25
  • 1
    Also read: [Memory Management in CPython](https://docs.python.org/3/c-api/memory.html) – Ashwini Chaudhary Aug 11 '17 at 10:29
  • 1
    If some objects are redundant then it's your issue. Python can't do anything about it, it's your responsibility to make sure unused objects don't have references anymore so that they can be garbage collected, else they are going to stay around. – Ashwini Chaudhary Aug 11 '17 at 10:31

0 Answers0