Out of Memory for using many global variables
1 回表示 (過去 30 日間)
古いコメントを表示
Hi
I have many functions. so instead of use the variables as function arguments to transfer values between functions. I set many variables as global variables. These global variables are not used all the time.
on the top of main function, I did use the following to clear the space.
clc clear all; close all; however, when opening a big excel file(200MB), I ran into out of memory issue for 2014b version. When I change it to use 2017 version. the issue was gone but loading speed for opening excel using xlread() is still very slow. Now I need your help on the following questions.
1. How to reduce memory space with many global variables? How to only assign space when it is used? 2. I have few toolboxes, like statistics, which are only linked to 2014b version. Is it possible to use these toolbox for 2017 version?
Thank you so much for your help. I appreciate it.
11 件のコメント
Walter Roberson
2018 年 2 月 9 日
If you have enough data to be running out of memory, you should be using setappdata()/getappdata() instead of guidata(). guidata() is invoked by GUIDE for every callback, and a copy of all the stored data is created each time. With setappdata()/getappdata(), you can pull in copies of just the data you need.
Even then, since the data is large, you should probably instead rewrite your code to use nested functions with shared variables -- or create a handle object containing the array, possibly using https://www.mathworks.com/help/matlab/matlab_oop/handle-compatible-classes-and-heterogeneous-arrays.html
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!