Reputation: 161
In Python, if I have a variable name and reset it with an object, could that eventually fill memory?
while True:
a = 'test string'
Upvotes: 1
Views: 1153
Reputation: 4472
Python is allocating memory for objects that created when referencing new variables if they not exist.
In your case, the memory allocation will take place once on the first iteration, and then it will keep referencing the same object in each iteration so it will not allocate the full memory that you have.
This loop can run until you will kill the process without warring about memory space.
Upvotes: 2