Steven G. Johnson <stevenj....@...> writes:

> 
> 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).
> 
> Steven
> 
I agree that it's very unlikely that NLOpt leaks memory.
It's API works like that:
- any memory allocated inside the library is de-allocated before the return of
the call;
- any pointers passed to the library are responsibility of the caller.

Apart from trying to debug the code, a good practice would be not to use any
pointers in your program at all: C++ code is much better off using STL or Boost
libraries. That way memory allocation will be taken care of by C++ :)
Dmitri

(On this note though, it would be good if memory management inside the library
is also based on smart/shared/auto pointers - in the current design any
exception thrown inside the caller's function would result in memory leak)



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

Reply via email to