Why do I receive an "Out of Memory" error when I use the WAVREAD or WAVWRITE function in MATLAB 7.1 (R14SP3)?

4 views (last 30 days)
The largest contiguous block of memory on my system is larger than 250 MB. When I try to read in a 250 MB WAV-file using WAVREAD, I receive an "Out of Memory" error.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Feb 2011
The ability to read or write WAV-files larger than the fourth largest block of contiguous memory is not available in MATLAB.
Two possible workarounds to memory limitations are:
1. To consider windowing, if it fits the application, by specifying a small subset of samples from a.WAV file at a given time for time-localized processing using the command
wavread(filename, [starting_sample, ending_sample])
2. Read data from the .WAV file in the native file format, instead of MATLAB's default double-precision by executing
wavread(filename, 'native')
This will help minimize memory usage further if the native file format encoded is of a precision less than 64-bit word size.
  1 Comment
Walter Roberson
Walter Roberson on 5 Oct 2018
The fourth largest block of contiguous memory?
So if I initialize MATLAB and all of the "large block" memory is a single contiguous heap, then the fourth largest block of contiguous memory would be one of the "small block" cache that MATLAB keeps internally. I do not happen to recall exactly the size of the small blocks -- 512 bytes? 4096 bytes? MATLAB never chains those blocks together: if an array grows past the blocksize, MATLAB allocates memory from the heap, looking for best-fit, potentially leading to memory fragmentation.
So, this article seems to be saying that unless I have happened to fragment the heap, that the largest WAV file I would be able to read it would be that small block size such as 512 bytes (minus any overhead.)
I don't think that was the intended meaning. It would make more sense to say something like contiguous memory was required equivalent to 8 bytes per sample per channel plus some temporary storage equal to (whatever). Because if I happen to have a large enough contiguous memory, it should have no problem splitting.

Sign in to comment.

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!