recruit-communications / pyqubo

Python DSL for constructing QUBOs from mathematical expressions.
https://pyqubo.readthedocs.io/
Apache License 2.0
177 stars 46 forks source link

Memory leak when repeatedly creating QUBOs with version 1.3.0 or higher #215

Open sshibata25 opened 1 year ago

sshibata25 commented 1 year ago

Description When QUBOs are created repeatedly, memory usage increases linearly and is not released until the process terminates. This behavior occurs in versions 1.3 and 1.4 , but not in 1.2.

To Reproduce Run below script with version 1.3.0 or higher

import pyqubo

def create_qubo():
    x = pyqubo.Array.create("x", 100, 'BINARY')
    constraint = (sum(x) - 1) ** 2
    model = constraint.compile()
    qubo, offset = model.to_qubo()
    return qubo, offset

if __name__ == '__main__':
    n_iter = 1000
    for i in range(n_iter):
        qubo, offset = create_qubo()
xjsong99 commented 1 year ago

I have met the same issue when I define array variable and compile my problem. Did you solve it now? My version is 1.4.

rookiebird commented 1 year ago

I meet same error. It seems the error is caused by compile function