Memory leak with ~ suppresed wavread function output
古いコメントを表示
Why is the following code:
[~,~,~,opts]=wavread('example.wav');
causing apparent readout of all signal data into the memory? (memory is freed immediately upon completion making it hard to spot) This causes 'Out of memory' error when attempting to only read a small 'opts' parameters portion from a large .wav file.
Quote from help: Using the tilde (~) operator, you can change the declaration of a function so that it ignores any one or more entries in the input argument list(...)This can help you to keep your workspace clear of variables you have no use for, and also help you conserve memory.
At the same time wavread('size') does not cause this type of problems.
The only workaround I found to tis problem is: [~,~,~,opts]=wavread('example.wav',0);
Kind regards
Michal
採用された回答
その他の回答 (1 件)
MatrixMichael
2012 年 2 月 26 日
0 投票
1 件のコメント
Jan
2012 年 2 月 27 日
The internal behaviour of ~ gets clear when you write a Mex-function. From inside the Mex (which is called as any other M-function also), you can get the value of nlhs, "Number of left hand side arguments". In an M-file this is "nargout". But there is no information available, if some of the outputs are ignored by using ~.
Because I write Matlab code compatible to version 2009a and earlier, I do not use the tilde, but "[dummy, dummy, dummy, opts]=..." and "clear('dummy')" afterwards if a large memory occupation is expected.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!