Where is 'persistent' data stored in compiled MATLAB programs?

时间:2018-12-03 13:14:12

标签: matlab caching persistent-storage

I have an application in MATLAB that caches data as it's loaded into itself. This data is 'cached' in functions through the use of the 'persistent' command. E.g.

persistent data
if isempty(data)
    data = getData() % function that reads data in
end

When this data is cached, where does it go? I've noticed the cache persists even if the program is closed and reopened. Is it being written to disk? Or is the cache being stored in memory?

Some details: this is a program created using Matlab Compiler Runtime, it's written using R2014b. I don't know how to check how big data might be, so any help in that regard would be a bonus.

EDIT: The cache is not persisting across instances of the program that I can see. I originally observed this in the uncompiled version of my program, and that would make sense because the cache would persist alongside the matlab instance.

1 个答案:

答案 0 :(得分:2)

它存储在内存中。如您在编辑中所观察到的,它应该在MATLAB会话中是持久的,但不能跨会话。如果您对其进行编译并在MATLAB Compiler Runtime上运行,则它不应在关闭并重新运行已编译程序的过程中持续存在-如果这样做,则是一个错误。

我从未见过这种情况在编译的可执行文件中发生,但是我见过这种情况在为MATLAB Production Server使用而创建的编译组件中发生(其中同一Runtime可以多次使用,并且它之间不能正确清除内容)电话)。