Increase of memory usage with standalone app

4 views (last 30 days)
Hi, I developed a standalone app using GUIDE and I structured the code with a callback function related to a pushbutton that executes cyclically a sequence of script (this cycle of execution lasts for 30-40s more or less). I use a while loop with a condition depending on a variable that is changed by another pushbutton callback. So, the idea is that the app has to work cyclically for days and days and I will stop it only if it is strictly necessary.
I've noted that the memory usage constantly increases over time. At each cycle of script execution the memory usage changes pseudo-randomly (increasing or decreasing), but the overall trend contains a significant drift (about 300MB / 2 hours). This causes a crash of other programs because of RAM saturation and I'm not able to understand why there is the drift. I tried to insert a clearvars at the end of the script sequence execution (within the while), but nothing changed. For your information, at each iteration of the while loop I create struct variables containing thousands of samples.
Do you have any suggestion to avoid this behavior, for example modifying the code structure or something else.
  1 Comment
Ryan Povall
Ryan Povall on 26 Jul 2016
One suggestion I have is to read through the articles from the following documentation page:
Specifically, there is the article named "Strategies for Efficient Use of Memory" that may be helpful in this case.
You can also use the "memory" command to display memory information and log that information to some external file by using the "diary" command.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!