On May 25, 2010, at 4:27 PM, Liang Wu wrote:
NLOPT is a very good optimization library. I want to keep using it.
I am just stuck with the memory issue.
For your question, I am using nlopt_minimize with algorithm NLOPT_LN_BOBYQA. I guess the memory leaking came from the going back and forth from C code to my C++ code when calling my object function (nlopt_func type). Some memory was not released after returning from my object function.
Maybe you can give me some suggestions if it does not bother you.

Hi Liang,

I just double-checked using a memory debugger (valgrind), and it doesn't look like NLOPT_LN_BOBYQA has any memory leaks, so I'm guessing that the memory leak is in your code, not in NLopt.

Just going back and forth between C and C++ should not create a leak. You must be allocating something (e.g. via new) and forgetting to deallocate it (delete).

There are a variety of ways to try to debug this (besides going through your code and looking for allocations you don't free). Under GNU/Linux, there is a nice memory debugging tool called valgrind that will tell you exactly where the leak is coming from; I'm not sure if there is any tool as good under Windows, although Google tells me that there are some leak-debugging tools under Windows that you might try. If you are stumped, another approach is to start deleting code, simplifying your function more and more until the leak goes away....when the leak disappears, you will know you just deleted the code that caused the problem.

Steven

_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to