Ask Your Question
1

Memory leak in Polyhedron?

asked 2019-07-22 09:15:08 -0500

Giove gravatar image

updated 2019-08-29 09:03:02 -0500

FrédéricC gravatar image

If I run the following code:

import gc

while True:
    P = Polyhedron([[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])
    faces = P.faces(3)
    del P, faces
    print "memory usage: " + str(get_memory_usage()) + ", gc: " + str(gc.collect())

the memory usage keeps increasing. Do you know what is the cause and how to avoid this problem?

edit retag flag offensive close merge delete

Comments

This memory leak in Polyhedron is fixed in this ticket.

jipilab gravatar imagejipilab ( 2020-04-23 02:57:24 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2019-08-27 04:30:29 -0500

jipilab gravatar image

This has been reported previously on sage-devel:

https://sage-devel.narkive.com/O7zoOj...

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).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-22 09:15:08 -0500

Seen: 95 times

Last updated: Aug 27 '19