Borrar filtros
Borrar filtros

How Do I free up a Fortran Mexed substructure (running out of memory-leaking memory)

2 visualizaciones (últimos 30 días)
I have a program inwhich matlab is calling a mexed Fortran 77 subroutine. Created in the mexed fortran file is a structure within structure for output. So I create these temporary structures that creates the main output structure.. So that all works fine......... Now its a matter of RELEASING these temporary subs structures because after the program gets called a few 1000 times, I get the low-memory notice, then soon matlab crashes and burns. I had the task manager showing me that the PF usuage does not drop back down after each call.
The temporary structures being created are using: tmpstruct = mxCreateStructMatrix(x,x,x,x)
I have tried at the end of the fortran file before it returns to matlab the following: mxfree(tmpstruct) and mxDestroyArray(tmpstruct) and the memory never never gets released until I shut down matlab or the memory leak shuts down matlab.
Any ideas ????

Respuestas (1)

Philip Borghesani
Philip Borghesani el 29 de Ag. de 2014
Editada: Philip Borghesani el 29 de Ag. de 2014
Unless you are calling mexMakeArrayPersistent I suspect you have another leak than that one. Matlab will eventually clean up all mxArrays (actuality any call to mxCreate... or mxMalloc) allocated by a mex file. It is best practice to do this yourself with mxDestroyArray (NOT mxFree) for performance and cleanliness reasons but not necessary especially if your code calls mexError...
I would look for any code that uses Fortran dynamic memory directly. Reduce your code to the minimum that leaks and post it here if you have not found the leak.

Categorías

Más información sobre Fortran with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by