Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This has been reported previously on sage-devel:

https://sage-devel.narkive.com/O7zoOjb4/memory-leak-in-polyhedron-objects

It is related to the creation of the whole(!) face lattice, even if it is not necessary. This is a problem caused by UniqueRepresentation of posets, see the trac ticket https://trac.sagemath.org/ticket/14356

Meanwhile, from the Sage version 8.9, CombinatorialPolyhedron are available, and one can do the following:

sage: import gc
sage: while True:
....:     P = Polyhedron([[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])
....:     CP = CombinatorialPolyhedron(P)
....:     faces = list(CP.face_iter(2))
....:     del P, CP, faces
....:     print("memory usage: " + str(get_memory_usage()) + ", gc: " + str(gc.collect()))
....:     
memory usage: 11593.33203125, gc: 269
memory usage: 11593.33203125, gc: 49
memory usage: 11593.33203125, gc: 49
memory usage: 11593.33203125, gc: 49
memory usage: 11593.33203125, gc: 49
memory usage: 11593.33203125, gc: 49
memory usage: 11593.33203125, gc: 49

The current plan is that the method .faces() from Polyhedron will be replaced by the above function which is much faster and does not have a memory leak.

(Note: in the above, I could not put 3 as dimension simply because the iterator requires to be a proper dimension).