TRootEmbeddedCanvas and X Window memory allocation problem

Hello,
I’m developing a standalone application (compiled with gcc) with a TGMainFrame and a lot of TRootEmbeddedCanvas.
I have a big problem with the memory allocated by the X Window system. When I create some TRootEmbeddedCanvases, for the first 2-3 canvases created the memory allocated by X Window don’t increase, but if I try to allocate more than 2-3 canvases the memory allocated by the X Window system increase drammatically of 4 Mb and more for each TRootEmbeddedCanvas (each canvas is usually divided in 4 pads).
My application show only 1 TRootEmbeddedCanvas at the same time (the others TRootEmbeddedCanvases are hidden with HideFrame() ). Each TRootEmbeddedCanvas is selected with a TListBox and is showed with ShowFrame().
A possibile solution should be to use only one TRootEmbeddedCanvas in my application, allocate the canvases that I need using the TCanvas class (instead of TRootEmbeddedCanvas) and associate the canvas that I would like to display (of class TCanvas) with the only TRootEmbeddedCanvas present by means of the TRootEmbeddedCanvas::AdoptCanvas().
But I’m not able to do this because when I allocate the canvases (using TCanvas class) they appear in the screen (with the same number of TCanvas the X WIndow system memory allocated is much less than TRootEmbeddedCanvas). How is possible to do this? For me is not possible to use only one canvas (TCanvas) and redraw all the object contained in the canvas because all the information modified by the user will be lost.
Thank you very much for every help.
Best regards
Andrea Bulgarelli

Hi Adrea,

I don’t see directly why a TCanvas would use less memory than a TRootEmbeddedCanvas. If you create a large amount of TCanvases you don’t see this behaviour?

Cheers, Fons.

Yes, if I create a lot of TCanvases I don’t see this behaviour.
Andrea

Hello, I have developed a small example that reproduce the problem.
You can try to add a lot of TRootEmbeddedCanvas and study how to increase the X windows memory after 4-5 canvas created.
This effect disappear if I don’t use the HideFrame. Comment the line 62 and add TRootEmbeddedCanvases.
It seems that the effect depends by the HideFrame.
Thank you

Andrea Bulgarelli
multiembedded.c (4.19 KB)

Hi Andrea,

Thank you for sending the example. I will have a look what is going on.

Best regards, Ilka

Hi Andrea,

Could you please provide details about the goal of your application. How many canvases you are going to create, do you need all of them to be available in your application and why not (for example) having one embedded canvas; can you draw what you want in one canvas and after save the TCanvas in a macro ? There might be another design solution also but to be able to help we need details.

Thank you, Ilka

The goal of my application is mainly to provide a quick look of the data coming from the scientific instrument during the assembly, integration and verification phase. This means that I need to refresh the data coming from the instrument during the acquisition of these data (in real time). For this reason the TCanvases that contains the graphs or histogram should be active (even if only one is showed to the user, the others are hidden, but the process of elaboration of the data is active). In addition, the user could change the properties of the object of a canvas and those changes should be maintained even if the canvas is hidden.
How many canvases I need in my application? It depends by the user choice, because my application is organized in chains and views.
A chain elaborate one particular type of data coming from the instrument, usually a chain correspond with a particular type of data into a file.
A view is a particular mode to display the data. It is possible to have a lot of view that display the same data coming from a particular chain. The user can choose all the views that are available and one view correspond with a TRootEmbeddedCanvas. It is possible to show only one view at the same time.
I think that a possible solution is having only one embedded canvas and display the TCanvas that are stored in a list in this TRootEmbeddedCanvas, but I’m not able to do this.
As attachment there are a screenshot of the software. In the left side are present the list of the views that it is possible to show (that are activated). In the right side is showed the TRootEmbeddedCanvas.
Thank you very much
Andrea Bulgarelli