python - Why memory usage keep growing when I repeatedly open and close the same file -
here code:
while true: open('a', 'w'): assert true # sth when run it, system total memory usage kept growing. 4 core cpu goes 100%.
why happening?
shouldn't linux kernel close fds , free memory ?
my environment:
- ubuntu 14.04 kernel: x86_64 linux 3.13.0-77-generic
- python 2.7.6
- cpu: intel core i3-2350m cpu @ 2.3ghz
- ram: 7878mib
now can't reproduce problem running original code:
def main(): key_list = "" in xrange(10000000, 1000000000): key_list = key_list + str(i) + "\n" if len(key_list) > 10000: open("./passwd1.txt", "a+") f: f.write(key_list) # del key_list key_list = "" print "done" weird...
Comments
Post a Comment