Ask Your Question
2

Memory leak when doing ANF of boolean functions?

asked 2016-11-17 09:50:56 +0100

sageuser1 gravatar image

updated 2016-11-17 14:45:05 +0100

I am using SageMath version 7.2 (EDIT: I confirm the same behavior under Sage version 7.4)

sage: B = random_boolean_function(3)
sage: get_memory_usage()
732.5078125
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
743.53125
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
749.04296875
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
754.6875
sage: B.algebraic_normal_form()
x0*x1*x2 + x0*x1 + x0 + x2
sage: get_memory_usage()
760.19921875

After each ANF call the memory used is rising. Is this a memory leak?

edit retag flag offensive close merge delete

Comments

I confirm the same behavior under Sage version 7.4

sageuser1 gravatar imagesageuser1 ( 2016-11-17 14:44:25 +0100 )edit
1

Thanks for reporting !

tmonteil gravatar imagetmonteil ( 2016-11-18 11:57:07 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-11-17 19:34:57 +0100

nbruin gravatar image

updated 2016-11-18 00:23:56 +0100

Yes, this is a memory leak. if you read the code you see that algebraic_normal_form creates a BooleanPolynomialRing every time. These stack up. A little work with objgraph.show_backref shows that there is a (global?) WeakValueDictionary linking to these objects, preventing them from being garbage collected.

There is likely some coercion map being cached.

It's now bug https://trac.sagemath.org/ticket/21892

edit flag offensive delete link more

Comments

Thank you for the update!

sageuser1 gravatar imagesageuser1 ( 2016-11-18 07:39:23 +0100 )edit
1

Thanks for the ticket !

tmonteil gravatar imagetmonteil ( 2016-11-18 11:57:19 +0100 )edit
1

Such parents should have unique representation, right ? So why are they not pointing to the same object ?

sage: B = random_boolean_function(3)
sage: a = B.algebraic_normal_form().parent()
sage: b = B.algebraic_normal_form().parent()
sage: a
Boolean PolynomialRing in x0, x1, x2
sage: b
Boolean PolynomialRing in x0, x1, x2
sage: a is b
False
tmonteil gravatar imagetmonteil ( 2016-11-18 11:59:39 +0100 )edit

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: 2016-11-17 09:50:56 +0100

Seen: 456 times

Last updated: Nov 18 '16