필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Rick
Rick 2014년 8월 29일
댓글: Rick 2014년 8월 29일
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 ????

답변 (1개)

Philip Borghesani
Philip Borghesani 2014년 8월 29일
편집: Philip Borghesani 2014년 8월 29일
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.

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by