3 level nested structs leading to out of memory
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Science Machine
am 14 Apr. 2022
Bearbeitet: Science Machine
am 14 Apr. 2022
I'm initializing nested structs as:
struct('nestedLevelOne', repmat({struct('nestedLevelTwo',repmat({zeros(1,1080)}, [1,540]))} , [1,100]));
When I access and store data to these structures this is leading memory issues with 192gb ram on my workstation. Is there I am doing wrong with this?
2 Kommentare
Akira Agata
am 14 Apr. 2022
I could generate this nested structure without any issue.
Could you tell us more detail on the process when you faced the memory issue?
By the way, I would recommend break-down your code to be read easily, like:
c1 = repmat({zeros(1,1080)}, [1,540]);
c2 = repmat({struct('nestedLevelTwo',c1)} , [1,100]);
yourStruct = struct('nestedLevelOne', c2);
Akzeptierte Antwort
Chunru
am 14 Apr. 2022
It takes ~472MB memory as shown below.
a = struct('nestedLevelOne', ...
repmat({struct('nestedLevelTwo',repmat({zeros(1,1080)}, [1,540]))} , [1,100]));
whos
a(1)
a(1).nestedLevelOne(1)
size(a(1).nestedLevelOne(1).nestedLevelTwo)
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!