Memory Overflow when looping over parser function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone, I'm trying to create a small benchmark script for a C++ written xtc-parser that should measure the function time for several files of different sizes. In order to minimize errors I want to use the mean of 1000 function calls which leads to the problem that MatLab is allocating more and more memory to save the loaded data. I assigned the to a variable to trick MatLab to overwrite the data and tried to use clear and clearvars but still the memory is not released and more memory is allocated. I'm currently using this code to generate my data and output file.
n=[1:1:10,20:10:100,200:100:1000,2000:1000:16000];
out=[0,0];
for i= n
path=['~/xtc_complex_',num2str(i),'.xtc'];
tic;
for j=1:1000
parseXtc(path);
end;
time=toc;
time2=time/1000;
time3=[1,time2];
out=cat(1,out,time3);
end;
csvwrite('/home/dombrowsky/Benchmark_complex_gro2mat.dat',out);
PS: I am not used to MatLab syntax and therefore every remark regarding my code would be highly appreciated.
0 commentaires
Réponses (1)
Jan
le 8 Déc 2016
Pre-allocating out is easy:
n = [1:1:10,20:10:100,200:100:1000,2000:1000:16000];
out = zeros(numel(n), 2);
for k = 1:numel(n)
i = n(k);
...
out(k, :) = time3;
end
But you n is such small, that I cannot imagine that this causes a memory overflow. More likely the problem is within parseXtc. Please mention the line, which causes the error.
2 commentaires
Voir également
Catégories
En savoir plus sur Performance and Memory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!