Matplot() is leaking memory, using graphic handle makes it worse
Reported by Antoine Monmayrant
leakage_per_element_Matplot_handles.png (13.81 KB, image/png)
Evolution of memory leakage with the number of elements to plot with Matplot()
BUG DESCRIPTION:
----------------
When calling several times Matplot() within a loop on a figure with auto_clear="on", there is a huge memory leak (45MB/iteration on a realistic situation).
<!> Note that : h=scf(); h.children.auto_clear="on"; means each new call to Matplot() should free up the figure content.
ERROR LOG:
----------
Depends whether the memory is exhausted and error message depends on how scilab is axed by the OS.
HOW TO REPRODUCE THE BUG:
-------------------------
Here are two scripts to trigger either a big or a smaller memory leak:
/*
Version 1: small leak: +1.919GB used after 250 iterations or ~7.9MB/iteration
*/
z=rand(2048,1248);
n=250;
h=scf();
h.children.auto_clear="on";
for i=1:250
Matplot(z);
end
/*
Version 2: big leak: ~45Mb per iteration. 250 iterations kills scilab)
*/
z=rand(2048,1248);
n=250;//kills my 8GB laptop
//n=100;// just fine
h=scf();
h.children.auto_clear="on";
for i=1:n
h.children.auto_clear="off";// toggling this handle property makes things >x5 worse!
Matplot(z);
h.children.auto_clear="on";
end
OTHER INFORMATION:
------------------
I ran tests to see how it depends on the length of the matrix to plot (z):
- we leak ~19Bytes per element in z with version 1
- we leak ~ 7Bytes per element in z with version 2
(see attached graphs)