I've been trying to learn file I/O in Python, but have come across some sort of memory leak that I can't solve for no apparent reason.
file = "D:\\babelStorage\\Testing"
x = 1000000
while (x > 0):
with open("".join([file, "\\", "junk", str(x), ".txt"]), "wt") as trash:
trash.write("garbage")
x = x - 1
The same issue seems to occur even when I explicitly use trash.close(). What exactly am I doing wrong that's causing huge chunks of memory to accumulate?
None of the memory shows up as a process on task manager. If I run it long enough I can get 10GB which are... somewhere. Closing the python shell doesn't recover the memory, either, I have to reboot.