[Solved] Memory consumption while loading layouts.

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Yevgeny
Just popping in
Just popping in
Posts: 7
Joined: Wed Oct 09, 2013 10:44

[Solved] Memory consumption while loading layouts.

Postby Yevgeny » Fri Dec 26, 2014 14:26

Hello!

I use CEGUI 0.7.7 with Ogre renderer. I call

Code: Select all

CEGUI::WindowManager::getSingleton().loadWindowLayout(root);

to load a list of 17 layout files. Each of them contains a lot of CEGUI elements, mostly StaticImage or ImageButton. Total amount of elements in all files is about 2500.
After calling loadWindowLayout() I've noticed huge memory consumption of 150 Mbytes(!).
All imageset atlas textures are much smaller and they are loaded before layouts.
Are there any mechanisms in CEGUI that can occupy this memory, internal buffers or something like this? AutoRenderingSurface property is False on every element.
Last edited by Yevgeny on Wed Jan 14, 2015 12:09, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Memory consumption while loading layouts.

Postby Ident » Fri Dec 26, 2014 21:57

Each window has a lot of properties, which are strings, that have to be stored, as well as a couple of other attributes. Multiplying that memory with 2500 can lead to quite some consumption, but 150 megabytes stills sounds too high to me. AutoRenderingSurface was a good shot by you, but you say it is always deactivated, so there is not much left that could cause such memory usage.

0.7.X is very old, I m mostly familiar with 0.8.X and default-repository code so I cannot really tell what is going on there. You could try to use some sort of tool that tracks memory consumption in a program maybe, in which case you should tell us the results, it might be valuable even for higher versions.

Or even easier: Try to only create certain types of windows and see if it makes a difference for the memory what type of window you create.
CrazyEddie: "I don't like GUIs"

Yevgeny
Just popping in
Just popping in
Posts: 7
Joined: Wed Oct 09, 2013 10:44

Re: Memory consumption while loading layouts.

Postby Yevgeny » Tue Dec 30, 2014 13:14

Thanks for your reply.

As a quick solution, I've just made loading/unloading of needed layouts.
Then I tried to load a layout with 100 TaharezLook/StaticImage's and got memory usage of 1.737.104 bytes.
With 100 TaharezLook/StaticText's I got 19.654.864 bytes.
So the problem is in StaticText - it is too heavy for frequent usage. It is also noted here:
http://cegui.org.uk/forum/viewtopic.php?f=3&t=2427

I'll try to find lightweight analog like Label or Caption.
Yes, 0.7.x is old, but changing to newer version right now in our project wasn't the point. .)

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Memory consumption while loading layouts.

Postby Ident » Tue Dec 30, 2014 13:34

There is a lightweight "Generic/Label" in 0.8.X . You might wanna try to adopt it into 0.7.X, should be easy.
CrazyEddie: "I don't like GUIs"

Yevgeny
Just popping in
Just popping in
Posts: 7
Joined: Wed Oct 09, 2013 10:44

Re: Memory consumption while loading layouts.

Postby Yevgeny » Tue Dec 30, 2014 13:39

Thanks, I will try.

Yevgeny
Just popping in
Just popping in
Posts: 7
Joined: Wed Oct 09, 2013 10:44

Re: [Solved] Memory consumption while loading layouts.

Postby Yevgeny » Wed Jan 14, 2015 12:15

Here are steps that I've made:

Copy/paste Label widget from TaharezLook.looknfeel of CEGUI 0.8.x to the same file in my CEGUI 0.7:

Code: Select all

<WidgetLook name="TaharezLook/Label">
  ...
</WidgetLook>


Add the following line to TaharezLook.scheme file:

Code: Select all

<FalagardMapping WindowType="TaharezLook/Label" TargetType="DefaultWindow" Renderer="Falagard/Default" LookNFeel="TaharezLook/Label" />


Change TaharezLook/StaticText to TaharezLook/Label in all my layout-files.

And that's it, 123 MBytes are back! Thanks!

Note that to vary color we now have to use NormalTextColour property instead of TextColours for StaticText.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Solved] Memory consumption while loading layouts.

Postby Ident » Wed Jan 14, 2015 15:22

Thanks for showing your solution! I am sure this will be helpful to some.


Btw which type of strings do you use? You might wanna use std::string instead of CEGUI::string to save extra memory space, but of course only if ASCII is enough for you.
CrazyEddie: "I don't like GUIs"

Yevgeny
Just popping in
Just popping in
Posts: 7
Joined: Wed Oct 09, 2013 10:44

Re: [Solved] Memory consumption while loading layouts.

Postby Yevgeny » Wed Jan 14, 2015 15:28

Strings and localization is not my area, it's up to my colleague, but when putting text into CEGUI windows we convert it to CEGUI::string. Anyway, we need multilanguage, so ASCII is not enough.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Solved] Memory consumption while loading layouts.

Postby Ident » Wed Jan 14, 2015 15:37

Then that is the only possibility atm. We don't support UTF-16 and UTF-8 yet. (We are open to contributions of course)
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests