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.
It’s stored in memory. It should be persistent within a session of MATLAB, as you observed in your edit, but not across sessions. If you compile it and run it against MATLAB Compiler Runtime, it should not persist across closing and rerunning the compiled program - if it does, that’s a bug.
I’ve never seen that happen with compiled executables, but I have seen it happen with compiled components created for use with MATLAB Production Server (where the same Runtime can be used multiple times, and it doesn’t correctly clear things between calls).