home › Forums › # Technical Support › Memory management › Reply To: Memory management
Hi temprt,
thank you for your post and for using fuzzylite.
Interesting question.
For C++ programmers, doing mSteer->addTerm(new Ramp(“right”, 0.000, 1.000));
may feel (very) unsafe and scary, and I understand that. However, when a term is added to the variable, the variable takes ownership of the term, and therefore deletes every term automatically upon deleting the variable. Likewise, the engine deletes the variables. All you need to do is make sure you delete the engine and the rest will be handled automatically for you. The nice structure and encapsulation of fuzzylite makes it easy to assign ownerships of objects.
You can take a look at:
https://github.com/fuzzylite/fuzzylite/blob/release/fuzzylite/src/Engine.cpp#L96
https://github.com/fuzzylite/fuzzylite/blob/release/fuzzylite/src/variable/Variable.cpp#L63
https://github.com/fuzzylite/fuzzylite/blob/release/fuzzylite/src/rule/RuleBlock.cpp#L67
Cheers.