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