#60: Fix memory leaks in k_order_perturbation DLL -------------------------+-------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: new Priority: minor | Milestone: Component: K-order DLL | Version: Keywords: | -------------------------+--------------------------------------------------
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: new Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: | Keywords: --------------------------+-------------------------------------------------
Comment(by sebastien):
Basically, the problem is that the current k-order code creates objects at several places (using "new" operator) without ever deleting them. This creates memory leaks, which are not a big issue in typical situations, but which can become problematic when for example running the code several times inside a loop, since memory consumption will grow and never decrease.
In my opinion, the use of pointers is a bad practice, and should be restricted to very rare cases. Objects should be allocated on the heap (by the calling function in the case of an output variable of a subfunction), or as data members of classes, but never (or so) by using "new" or "malloc". That way, memory will always be correctly deallocated, and many potential errors (such as seg faults) are avoided.
Fixing this in k_order_perturbation DLL implies to change the interface of several functions, in particular those who use pointers for input or output arguments. Passing-by-reference should be used for both input and output (using a "const" for inputs).
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: accepted Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: | Keywords: --------------------------+------------------------------------------------- Changes (by george):
* status: new => accepted
Comment:
As an emergency bug fix I removed (i.e. delete-d) few objects created by operator "new" in calcDerivatives and the constructor. Please check if that is causing any problem on your machines. This change so far did not require changes of the interfaces.
In due course I will continue working on further improvements such as changing the style and using references instead of pointers, though, at a lower priority.
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: accepted Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: | Keywords: --------------------------+-------------------------------------------------
Old description:
New description:
Thanks for that.
Let's leave open this bug, and only close it when we are sure there is no remaining memory leak. This indeed involves some refactoring (using references whenever possible), but this is not of highest priority.
--
Comment(by sebastien):
Replying to [comment:2 george]:
As an emergency bug fix I removed (i.e. delete-d) few objects created by
operator "new" in calcDerivatives and the constructor. Please check if that is causing any problem on your machines. This change so far did not require changes of the interfaces.
In due course I will continue working on further improvements such as
changing the style and using references instead of pointers, though, at a lower priority.
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: accepted Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: | Keywords: --------------------------+-------------------------------------------------
Old description:
Thanks for that.
Let's leave open this bug, and only close it when we are sure there is no remaining memory leak. This indeed involves some refactoring (using references whenever possible), but this is not of highest priority.
New description:
--
Comment(by sebastien):
Replying to [comment:2 george]:
As an emergency bug fix I removed (i.e. delete-d) few objects created by
operator "new" in calcDerivatives and the constructor. Please check if that is causing any problem on your machines. This change so far did not require changes of the interfaces.
In due course I will continue working on further improvements such as
changing the style and using references instead of pointers, though, at a lower priority.
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: accepted Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: | Keywords: --------------------------+-------------------------------------------------
Comment(by sebastien):
Thanks for that.
Let's leave open this bug, and only close it when we are sure there is no remaining memory leak. This indeed involves some refactoring (using references whenever possible), but this is not of highest priority.
#60: Fix memory leaks in k_order_perturbation DLL --------------------------+------------------------------------------------- Reporter: sebastien | Owner: george Type: bug | Status: closed Priority: minor | Milestone: Component: K-order DLL | Version: Resolution: fixed | Keywords: --------------------------+------------------------------------------------- Changes (by sebastien):
* status: accepted => closed * resolution: => fixed
Comment:
Fixed in commits bb3675e75c9787a864557ff659b134384273dca0, d95b0cf6d7f2a11b75ea1da50c701af9a5cfe4df and 2449a4365c71411b61284264c7baf86705e15290