Memory Leaks using MEX file
4 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am running a matlab simulation which calls a MEX file for thousands of times in each simulation step. I use the "memory" command and find the memory usage of matlab is increased by 300 MB per step. This amount of memory is not used by workspace and it seems that it disappears on my computer. I have to quit matlab to release it.
I suppose this problem is called memory leak and has been discussed a lot. I am not a Java or C/C++ expert, are there any methods that I can reallocate or free the leaked memory after each simulation step?
Thanks a lot
Dan
0 件のコメント
回答 (1 件)
James Tursa
2013 年 4 月 9 日
If your mex file has a bug in it that is leaking memory, then the only thing you can do is get your hands on the source code, fix the bug, and recompile it. Once the memory is leaked (and I mean really leaked, not just temporarily leaked that gets recovered with garbage collection) there is nothing you can do to recover it short of quitting MATLAB and starting over.
3 件のコメント
James Tursa
2013 年 4 月 9 日
I am aware of emlmex but I don't know the details of how it creates the mex routine. You might consider looking at the optional inputs for the emlmex command ... maybe you can force it to do something slightly different that doesn't leak memory.
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!