nset = 1e3; npts = logspace (3, 4, 2); ## Initial memory info tmp = memory (); m0(1) = tmp.MemUsedOctave () m0(2) = tmp.VirtMemUsedOctave () m = zeros (numel (npts), nset, 2); ## Plot data npts = logspace (3, 6, 4); hf = figure (); for ii = 1:numel (npts); ii close (hf); hf = figure (); n = npts(ii); h = plot (rand (1, n)); for jj = 1:nset jj set (h, "ydata", rand (1,n)) ## h = plot (rand (1, npts)); tmp = memory (); m(ii,jj,1) = tmp.MemUsedOctave (); m(ii,jj,2) = tmp.VirtMemUsedOctave (); endfor endfor clf; hold on; box on; grid on for ii = 1:numel (npts) x = ((ii-1)*npts + 1):(ii*npts); plot (x, (m(ii,:,1) - m0(1)) / 1e3, sprintf (";%d pts;", npts(ii))) p = polyfit (x(100:end), (m(ii,100:end,1) - m0(1)), 1); text (x(200), (m(ii,100,1) - m0(1)) / 1e3, sprintf ("~%3.1f kB/call", p(1)), "verticalalignment", "top") endfor hl = legend (); set (hl, "location", "east"); ylabel "MemUsedOctave (MB)" xlabel "Number of 'set' calls"