Code Monkey home page Code Monkey logo

Comments (6)

jyaif avatar jyaif commented on August 20, 2024 1

thread keyword to allow people like me to find it more easily:
memory leak

from kiwi.

sccolbert avatar sccolbert commented on August 20, 2024

In general, a variable can exist in more than one constraint, and tracking when a variable no longer appears in any constraints would be expensive. If you want to fully clear a solver, you can call solver.reset() which will remove everything.

from kiwi.

zevlg avatar zevlg commented on August 20, 2024

Yes, but uncontrollable growing is sometimes more troblesome than expenses due to variables cleanup. That is exactly my case, long run solver with frequently changing constraints set eventually leaks all the RAM.

Can you please provide some hints how to implement variables cleanup functionality?

from kiwi.

sccolbert avatar sccolbert commented on August 20, 2024

In Enaml, such unbounded growth could occur by continuously adding and removing new widgets from a layout, but Enaml deals with this case by resetting the solver when it gets new layout items and re-adding all relevant constraints.

https://github.com/nucleic/enaml/blob/master/enaml/layout/layout_manager.py#L295

I would suggest you follow a similar model and pick a reasonable time to reset the solver and then re-add all of your still-valid constraints. Checking whether a variable is still contained in the solver requires a linear scan over all rows in the solver. For a constraint with M variables, that would be an O(M x N) operation. Scanning for all empty variables would be O(N^2), at which point it's just cheaper to reset.

from kiwi.

sccolbert avatar sccolbert commented on August 20, 2024

Alternatively, you can reuse your old variables in your new constraints. i.e. manage your own free variable pool.

from kiwi.

zevlg avatar zevlg commented on August 20, 2024

Thanks! Periodically reset and re-add constraints should work for me.

from kiwi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.