How should I release memory while running an AppDesigner app without having to restart MATLAB?

28 views (last 30 days)
Hello,
I built a software to read and communicate voltage data to LabJack. The software sends voltage to three pistons in order to apply a load scheme that follows a sine wave. It also reads voltage from load cells and reads the displacement of the pistons (all of this data is presented to the user on the GUI- see picture). The software is meant to run for at least 3 weeks to control a lab experiment. However, MATLAB seems to consume all of my lab computer memory on day 5 which is not ideal for the conditions of my experiment.
The app relies on three timers with period 200 ms (one timer for each chamber/piston) to communicate voltage values with LabJack and another set of three timers that update every second to present numerical values of load and displacement.
I have looked thoroughly for a solution and I cannot seem to find any piece of code or information on how to release the memory being used by MATLAB without having to restart MATLAB.
I also noticed that closing the Appdesigner software does not release any memory. Starting a new experiment on the software which involves clearing variables also does not release any memory. The only way to release memory is by restarting MATLAB, which is not ideal. So I wonder if there is a better way to solve this issue?
BTW the plot in the GUI only plots the last 30 seconds of data and it updates every 200 ms.
Thanks,
Ward

Answers (1)

Mario Malic
Mario Malic on 19 Dec 2020
Hi Ward,
Do you use persistent variables? See in task manager which process has high memory usage, MATLAB or MATLABWindow?
Here's a link of different clears that you could do, try clearing in this order and see at which one memory will be released.
clearvars
clear functions
clear classes
clear all
  4 Comments
Mario Malic
Mario Malic on 20 Dec 2020
Just to try this option as well, since I forgot to mention it
clear
Do you use functions like evalin or assignin? When you get this warning about clearing classes, can you try Ctrl+C and see if you get any error or another warning? Probably, it's better to consult with customer support, this is quite a specific case.
WSS
WSS on 26 Dec 2020
Edited: WSS on 26 Dec 2020
Mario,
I tried using
clear
It does not do much. I also do not use any of the functions you mentioned.
CTRL+C will stop the timers and produce an error related to that event although it still does not clear memory.
I will contact customer support and see what they think.

Sign in to comment.

Categories

Find more on Environment and Settings 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!