First time here? Check out the FAQ!

Ask Your Question
1

Memory leak in Polyhedron?

asked 5 years ago

Giove gravatar image

updated 5 years ago

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?

Preview: (hide)

Comments

This memory leak in Polyhedron is fixed in this ticket.

jipilab gravatar imagejipilab ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

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

Preview: (hide)
link

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: 5 years ago

Seen: 873 times

Last updated: Aug 27 '19