On Wednesday, April 30, 2014 7:19:12 AM UTC-7, pete.d...@port.ac.uk wrote: > > Hi all, > > I'm pretty new to Python, so perhaps I'm doing something wrong, but I've > encountered what I believe to be a memory leak in Sage's Cone.dual() method. > Below is some very simplified proof of concept code demonstrating the issue: > > #!/usr/bin/env sage > generators = [] > generators.append( [1,0,0,0] ) > generators.append( [0,1,0,0] ) > generators.append( [0,0,1,0] ) > generators.append( [0,0,0,1] ) > for i in range( 0, 1000 ): > cone = Cone( generators ) > dual = cone.dual() > print( 'Current memory usage: ' + str( get_memory_usage() ) ) > > > Memory usage steadily increases with each iteration of the for loop. > Commenting out the line dual = cone.dual(), or moving the line cone = > Cone( generators ) before the for loop keeps memory usage constant. I'm > currently using Sage 6.0 on Ubuntu 13.10 32-bit, but have seen the same > behaviour in Sage 6.1.1 on Ubuntu 64-bit. >
This code: generators = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] import gc from collections import Counter cone = Cone( generators ) dual = cone.dual() gc.collect() pre={id(p) for p in gc.get_objects()} for i in range( 0, 2000 ): cone = Cone( generators ) dual = cone.dual() gc.collect() gc.collect() gc.collect() T=Counter([str(type(p)) for p in gc.get_objects() if id(p) not in pre]) [(t,c) for t,c in T.iteritems() if c > 10] confirms a memory leak in, e.g., 6.0 (you see all kinds of objects pile up in memory), but in 6.2.rc0 there is not, and I see flat memory usage. So it seems the leak is fixed in a future version. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.