Thanks very much for your kind answer!
>First of all, how do you measure the memory used by the GUI?
Our UI process is based on MyGUI, so we simply calculate the total memory used by UI process with/without starting UI process.
We use "assignWidget" to bind with image resource, so we can also calculate the memory usage for specific presenter.
>Do you know for sure that MyGUI is the culprit when it comes to memory? In that case, how? And what exactly in it is taking so much memory?
Ram memory for our UI process is limited , and the image resource is about 30M(png,pixel is 1920*1080 for 3 presenter), when all image resources are loaded into memory, it costs too much memory.
We have to free the memory of not showing presenter when enter into one screen, the problem is we don't now how to delete all relative resources for
one presenter.
btw,the following is the function we used for free widget resources
int totalcnt=0, succcnt = 0;
ReleaseWidgetResource(mMainWidget, totalcnt, succcnt); // to free current present mMainWidget and its child-wigdet texture resource
Code: Select all
void ReleaseWidgetResource(MyGUI::Widget* widget, int &total_cnt, int &suc_cnt){
int chil_cnt = 0;
MyGUI::EnumeratorWidgetPtr childs = widget->getEnumerator();
while (childs.next()){
total_cnt++;
chil_cnt++;
MyGUI::ITexture* pRes = MyGUI::OgreRenderManager::getInstance().getTexture(childs.current()->_getTextureName());
if(pRes != nullptr){
suc_cnt++;
if(setString.find(childs.current()->_getTextureName().c_str()) == setString.end()){
MyGUI::OgreRenderManager::getInstance().destroyTexture(pRes);
pRes = nullptr;
}
//MyGUI::OgreRenderManager::getInstance().destroyTexture(pRes);
}
//MyGUI::EnumeratorWidgetPtr ppchilds = childs->getEnumerator();
ReleaseWidgetResource(childs.current(), total_cnt, suc_cnt);
}
}
>If that is the case, I don't see the other 2 screens as taking much resource at all, probably less than 500 bytes or so (because materials and their >pointer to a texture takes very little memory), because you are still using the UI texture on the screen visible anyway.
Yes, you are right, the pointer itself will not cost too much memory, but the resource it points to(material, widget) really cost too many memory,
and the memory after first bind with assignwidget/settexture will remain used status, this is the part that we want to free, we want to know is there
any existing function for us to free them, or other similar function like ReleaseWidgetResource we can use to free material objects and corresponding texture?