New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python memory allocator: Free memory #41581
Comments
This is the second version of my Python memory allocator patch. http://mail.python.org/pipermail/python-dev/2005-January/ This patch enables Python to actually return memory to the The patch modifies obmalloc.c. If it is accepted, other |
Logged In: YES Please ignore this patch for the moment: I'm in the process of making |
Logged In: YES As per the discussion on python-dev, I've removed the concurrency hack. |
Logged In: YES Whoops! I uploaded a "fixed" version a while ago, but I guess I didn't |
Logged In: YES Assigned to me. |
Logged In: YES The patch here is out of date, but that's OK. I created |
Logged In: YES Great news! If you need any assistance, I would be more than |
Logged In: YES The tim-obmalloc branch was merged to the trunk (for Python |
Logged In: YES Note, that this patch doesn't fix all memory leaks of this AFAIK restarting python processes is still needed to reduce <pre> import random
import os
def fill(map):
random.seed(0)
for i in xrange(300000):
k1 = (random.randrange(100),
random.randrange(100),
random.randrange(100))
k2 = random.randrange(100)
if k1 in map:
d = map[k1]
else:
d = dict()
d[k2] = d.get(k2, 0) + 1
map[k1] = d
if __name__ == "__main__":
os.system('ps v')
d = dict()
fill(d)
print "-"* 50
print "\n" * 3
os.system('ps v')
del d
import gc
gc.collect()
</pre> |
Logged In: YES I have done some more tests... and it seems that Here is a modification of the last example posted. If you only let fill2() run almost all the memory is freed. It is still much better than python2.4, however I think <pre> import random
import os
def fill_this_one_doesnot_free_much_at_all(map):
random.seed(0)
for i in xrange(300000):
k1 = (random.randrange(100),
random.randrange(100),
random.randrange(100))
k2 = random.randrange(100)
if k1 in map:
d = map[k1]
else:
d = dict()
d[k2] = d.get(k2, 0) + 1
map[k1] = d
def fill(map):
random.seed(0)
for i in xrange(3000000):
map[i] = "asdf"
class Obj:
def __init__( self ):
self.dumb = "hello"
def fill2(map):
a = []
for i in xrange(300000):
o = Obj()
a.append(o)
return a
if __name__ == "__main__":
import time
import gc
os.system('ps v | grep memtest')
d = dict()
a = fill2(d)
#a2 = fill(d)
a2 = fill_this_one_doesnot_free_much_at_all(d)
print "-"* 50
print "\n" * 3
os.system('ps v | grep memtest')
del d
del a
gc.collect()
time.sleep(2)
for x in xrange(100000):
pass
print "-"* 50
print "\n" * 3
os.system('ps v | grep memtest')
</pre> |
Logged In: YES As the NEWS entry says, """ An instrumented debug build of current trunk showed that A large part of the relatively disappointing result we see |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: