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

29 次查看(过去 30 天)
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

回答(1 个)

Mario Malic
Mario Malic 2020-12-19
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 个评论
Mario Malic
Mario Malic 2020-12-20
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 2020-12-26
编辑:WSS 2020-12-26
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by