you can force a garbage collection with import gc gc.collect()
But your script doesn't increase memory on Sage-6.2.rc0 even without that. On Wednesday, April 30, 2014 3:19:12 PM UTC+1, 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. > > Can anyone shed any light on this? Is it a genuine bug, or am I doing > something unwise due to not understanding Python's garbage collection? Can > anyone suggest a workaround to force cone and dual to be freed on each > iteration of the for loop? I've tried using del cone and cone = None at > the end of the loop, but neither helped. > > Thanks in advance... > Pete > -- 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.