From: Jan Simon on
Dear Verma,

> I am clearly able to see that number of GDI handles and User Handles keeps growing
> with time (reaches 9000 in 3 hrs). Memory itself is not growing so much (~300 MB, while 1.5 GB is unused).
>
> But I am clearing all axes (cla) before redrawing new graphs. Any guesses on why
> handles may be growing with time?

It seems like you create the objects not in the current axes object, which is cleared by CLA. Perhaps you create a new AXES in each iteration?
However, this cannot be answered by the newsgroup, but by your debugger. Go to your program step by step and look, where objects are created and deleted. Search for all created axes:
findall(gcf, 'type', 'axes')

Kind regards, Jan
From: Yair Altman on
> I am clearly able to see that number of GDI handles and User Handles keeps growing
> with time (reaches 9000 in 3 hrs). Memory itself is not growing so much (~300 MB, while 1.5 GB is unused).
>
> But I am clearing all axes (cla) before redrawing new graphs. Any guesses on why
> handles may be growing with time?

This happens because the GUI handles are not deleted properly. Perhaps you leave a trail of handle references without clearing/deleting them, and perhaps due to some internal Matlab bug.

In any case, instead of clearing the axes and other GUI handles, try to reuse them by simply modifying their properties. This will both improve performance and reduce the number of newly-created GDI handles.

Yair Altman
http://UndocumentedMatlab.com