I find out where the problem is. I should not use the pause function as a timer, it seems to stop every thing matlab is doing include the bacground process. This problem can be solved by change it to
RUL_period=5;% do collection every 30 second
tic;
while toc<=RUL_period
%Matlab donothing
end
And the memory is not decreasing now
RUL collecting start
Memory before save audio: 4388.5548 MB
Memory afeter save audio: 4376.501 MB
Number of collected: 1
Memory before save audio: 4391.1365 MB
Memory afeter save audio: 4379.4457 MB
Number of collected: 2
Memory before save audio: 4390.8809 MB
Memory afeter save audio: 4377.8556 MB