Data Acquisition Toolbox    

Example: Managing Memory Resources

Suppose you create the analog input object ai for a sound card, add two channels to it, and configure a four second acquisition using a sampling rate of 11.025 kHz.

You return the default block size and number of blocks with the BufferingConfig property.

You return the memory resources with the daqmem function.

The UsedBytes field tells you how much memory is currently used by ai, while the MaxBytes field tells you the maximum memory that ai can use to store acquired data. Note that the value returned for MaxBytes depends on the total available computer memory, and might be different for your platform.

You can verify the UsedBytes value with the formula given in the previous section. However, you must first find the size (in bytes) of each sample using the daqhwinfo function.

The value of the NativeDataType field tells you that each sample requires two bytes. Therefore, the initial allocated memory is 122,880 bytes. However, if you want to keep all the acquired data in memory, then 176,400 bytes are required. The Data Acquisition Toolbox will accommodate this memory requirement by dynamically increasing the number of data blocks after you start ai.

After all the data is acquired, you can examine the final number of data blocks used by ai.

The final total memory used is

Note that this was more than enough memory to store all the acquired data.


  How Much Memory Do You Need? Glossary