Page 1 of 1

Memory usage

Posted: Sat Mar 03, 2007 14:09
by zhk_tiger
I found some frequently used widgets are realized not cheap, such as StaticText. It owns two scrollbars, a scrollbar owns three PushButtons.

The following table shows the memory grows up during a StaticText creating: (Unit:KB)

Code: Select all

      Mem Usage   VM Size   Total   Cost
      18772      14828   33600   
StaticText
self created   18812      14868   33680   80

Children ScrollBars
created      19168      15224   34392   712


So you can see the ScrollBars cost 712KB. Most time we only need a simple text widget, like a Caption(with Font and Color properties), we need not the ScrollBars.

And for a Game GUI, there will be likely up to 100 Caption widgets(without scrollbars) needed, if we use the current StaticText, we wasted 712KB*100 = 71.2MB memory.

So I strongly suggest it is better to add a cheap Caption widget. And for other widget realization, it is also better when the realization is cheep.

Regards,
zhk_tiger

Posted: Mon Mar 19, 2007 14:49
by mrp
I'm findind similar memory implications of using CEGUI. Was using Ogre 0.15.2 with old CEGUI and then moved to 0.4.1 on 1.2.5 Ogre, and everything has ballooned. I have a number of screens with tables drawn with staticText boxes and these screens are HUGE in memory - having to rewrite a mammoth chunk of code to try and get this down!!

Posted: Mon Mar 19, 2007 21:47
by Pompei2
If you already move to a "new" CEGUI version, wouldn't it be better to move to 0.5.0 ?

Posted: Tue Mar 20, 2007 09:29
by mrp
Very good point - yes I agree, I should, but I am concerned that I have a screen with lots of statictext boxes on and its over 70Mb in size - I create all my GUI screens at boot time at the moment, and so I've changed that to dynamic creation - but then I suffer with another problem that I've posted about elsewhere where it takes longer and longer each time the screen is created. I also don't seem to free up any space when destroying the GUI and subsequently cleaning the dead pool!

Maybe 0.5.0 will fix all these issues.

Posted: Thu Mar 22, 2007 07:07
by zhk_tiger
I have added a Caption widget(no scroolbars, has Text, Font, TextColor, Alignments) to the CEGUI project we are using(V0.4.1), the memory usage has decreased greatly. Also the creation time is greatly saved.

StaticText in CEGUI 0.5 still has scroolbars, so i do not think the memory usage will be much better.

Posted: Thu Mar 22, 2007 11:29
by mrp
@zhk_tiger: any chance of supplying some code for your caption widget? would be a great help ;)

Posted: Thu Mar 22, 2007 17:56
by lindquist
The first thing I've done in my CEGUI projects is create a simple Label looknfeel for DefaultWindow that acts as a static text without scrollbars.

Dont know why we dont have this in the default skins.

I wont mind adding this. And suggest the name <Skin>/Label

But it wont be for 0.4 as that would require code changes as well.

Posted: Fri Mar 23, 2007 09:23
by mrp
lindquist that would be great! I will take steps over the coming week to move to 0.5 and then I can implement this.

Cheers