Freeing up memory occupied by mex ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Freeing up memory occupied by mex ?

Rishi Amrit
Hi,

    I am using IPOPT ( https://projects.coin-or.org/Ipopt ) nonlinear solver for solving some large scale NLP's. It's used with Octave via mex interface provided along with the package. Quite expectedly, while solving large scale problems, memory usage will be high. Once an IPOPT call is finished, Octave still uses a lot of my system memory untill I exit. If I save all the variables in the workspace in a mat file, after the ipopt call, exit octave, restart it and load the variables back, I do not have Octave using all the memory it was using in the last call. So it seems the mex interface did not clean up the memory before coming out of the call. Is there a way to free up all that heavy memory that was being used by the mex function, without having to restart octave ?

Thanks,

Best,
Rishi

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Freeing up memory occupied by mex ?

John W. Eaton
Administrator
On 21-Jan-2009, Rishi Amrit wrote:

|     I am using IPOPT ( https://projects.coin-or.org/Ipopt ) nonlinear solver
| for solving some large scale NLP's. It's used with Octave via mex interface
| provided along with the package. Quite expectedly, while solving large scale
| problems, memory usage will be high. Once an IPOPT call is finished, Octave
| still uses a lot of my system memory untill I exit. If I save all the
| variables in the workspace in a mat file, after the ipopt call, exit octave,
| restart it and load the variables back, I do not have Octave using all the
| memory it was using in the last call. So it seems the mex interface did not
| clean up the memory before coming out of the call. Is there a way to free up
| all that heavy memory that was being used by the mex function, without
| having to restart octave ?

The code in Octave that calls mex functions should free all memory
allocated with the mex/mx functions on exit.  Are you sure that the
leak is not in the ipopt code itself?

After calling ipopt, what happens if you clear all variables in the
workspace?

jwe
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Freeing up memory occupied by mex ?

Rishi Amrit
On Wed, Jan 21, 2009 at 9:41 AM, John W. Eaton <[hidden email]> wrote:
The code in Octave that calls mex functions should free all memory
allocated with the mex/mx functions on exit.  Are you sure that the
leak is not in the ipopt code itself?

After calling ipopt, what happens if you clear all variables in the
workspace?

I ran a test. When I start octave, it starts using 30 Megs of RAM. After the end of ipopt call, memory usage by octave is 600 MB. Clearing all the variables with 'clear all' clears the workspace but does'nt flush the memory and octave still uses 600 MB's. So definitely the workspace variables are not using all that memory. Does that indicate a memory leak in ipopt code ? I should also mention, ipopt is also calling sundials toolboox for gradient estimation, which also is a mex call. Sundials has a CVodefree function that is supposed to clear memory used by CVode function, and I am using that function appropriately. So the possibility of Sundials being the culprit is probably less.

Thanks,

Rishi


_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Freeing up memory occupied by mex ?

John W. Eaton
Administrator
On 21-Jan-2009, Rishi Amrit wrote:

| On Wed, Jan 21, 2009 at 9:41 AM, John W. Eaton <[hidden email]> wrote:
|
| > The code in Octave that calls mex functions should free all memory
| > allocated with the mex/mx functions on exit.  Are you sure that the
| > leak is not in the ipopt code itself?
| >
| > After calling ipopt, what happens if you clear all variables in the
| > workspace?
|
|
| I ran a test. When I start octave, it starts using 30 Megs of RAM. After the
| end of ipopt call, memory usage by octave is 600 MB. Clearing all the
| variables with 'clear all' clears the workspace but does'nt flush the memory
| and octave still uses 600 MB's. So definitely the workspace variables are
| not using all that memory. Does that indicate a memory leak in ipopt code ?
| I should also mention, ipopt is also calling sundials toolboox for gradient
| estimation, which also is a mex call. Sundials has a CVodefree function that
| is supposed to clear memory used by CVode function, and I am using that
| function appropriately. So the possibility of Sundials being the culprit is
| probably less.

How do you know that CVodefree is really freeing all the memory
allocated?  Maybe there is a bug there?  Or in ipopt?

If you think this is a bug in Octave, then please submit a complete
bug report to the [hidden email] list.

Can you produce a small self-contained example (not relying on ipopt
or sundials) that shows that Octave's mex interface can result in
memory leaks?

What version of Octave are you using?

jwe
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave