How Do I free up a Fortran Mexed substructure (running out of memory-leaking memory)
1 回表示 (過去 30 日間)
古いコメントを表示
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 ????
0 件のコメント
回答 (1 件)
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 Center および File Exchange で Fortran with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!