clear after save in -v7.3 in script does not free memory

1 view (last 30 days)
Hi,
I run a postprocessing script on data saved from a simulation before feeding it back into another Simulink model. It's a large simulation with a lot of data generated. Since I only have 8Gb of memory, I can't postprocess all the data at once. So I have a script that runs over a smaller part of the data, then saves the step in a file and then moves on to the next part of data. The postprocessed data are timeseries that are later read in by Simulink again. Thus the files must be saved in -v7.3. This is where the problem lies. In the postprocessing file I want to achieve the following:
load datafile datapart_1;
do something on datapart_1;
save altered_datapart_1 altered_datapart_1 -v7.3;
clear datapart_1 altered_datapart_1;
load datafile datapart_2
do something on datapart_2
save altered_datapart_2 altered_datapart_2 -v7.3
clear datapart_2 altered_datapart_2
etc etc....
However, looking at the taskmanager performance monitor, the clear command does nothing while the script is running. Memory keeps filling up and I end up swapping to harddisk as the process progresses to datapart_15!!! My swapfile has grown to 25Gb!!!! I've narrowed it down to the -v7.3 option in the save command preceding the clear. In -v7 or older mode it doesn't happen and memory is freed after every step. However, I can not read it in with the second Simulink model.
Has anybody got a solution to this that does not involve changing anything in the Simulink models I use?
Kind regards,
sjerra
[EDITED, Jan, please format your code - thanks]
  5 Comments
sjerra
sjerra on 29 Dec 2013
I'm not getting that warning, no. But the behaviour is the same and only when handling timeseries saved in v7.3. I also discovered than when I load the saved variables from file, I can't clear them from the memory without restarting matlab so I assume it stems at least from a similar bug. Brilliant.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!