Ask Your Question
2

Memory leak when doing ANF of boolean functions?

asked 2016-11-17 02:50:56 -0500

sageuser1 gravatar image

updated 2016-11-17 07:45:05 -0500

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 07:44:25 -0500 )edit
1

Thanks for reporting !

tmonteil gravatar imagetmonteil ( 2016-11-18 04:57:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-11-17 12:34:57 -0500

nbruin gravatar image

updated 2016-11-17 17:23:56 -0500

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 00:39:23 -0500 )edit
1

Thanks for the ticket !

tmonteil gravatar imagetmonteil ( 2016-11-18 04:57:19 -0500 )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 04:59:39 -0500 )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 02:50:56 -0500

Seen: 88 times

Last updated: Nov 17 '16