How to calculate used memory of a m file
4 ビュー (過去 30 日間)
古いコメントを表示
How can I calculate the total memory used by an m file?
0 件のコメント
回答 (2 件)
Jan
2011 年 8 月 17 日
You can't.
You can use the command memory to estimate the memory consumption while the m-function is running. But this cannot be an exact measurement, because the the used memory depends on many different factors. E.g. a simple loop can consume more memory as it needs:
% *no* pre-allocation!
for i = 1:1e6
x(i) = 1;
end
Although the program needs just 8MB, the memory manager has to work extremly hard. There is no direct method to measure the problem quantitatively, because after the loop is ready, a garbage collection can reduce the consumed memory again.
Please explain the underlying problem. Perhaps a better solution canbe found.
0 件のコメント
Friedrich
2011 年 8 月 17 日
Like Jan said, you can't.
But this is a nice tool and maybe it helps you.
On Windows Systems you can use:
feature memstats
to get detailed memory information.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Performance and Memory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!