is a BUG? memory leak please hlep me.
1302769950
20-10-2012 04:25:04
I am Chinese . sorry for my english.
this is a very sample test. see code ,very sample
MyGUI::ImageBox* aaa;
MyGUI::ImageBox* bbb;
//create aaa and create a child imagebox
aaa=MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("ImageBox",300,300,50,50,MyGUI::Align::Center,"Back");
MyGUI::ImageBox* child1=aaa->createWidget<MyGUI::ImageBox>("ImageBox",0,0,50,50,MyGUI::Align::Center);
child1->setImageTexture("ItemBox.png");
child1->setImageCoord(MyGUI::IntCoord(81,106,50,50));
//create bbb and create a child imagebox
bbb=MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("ImageBox",300,300,50,50,MyGUI::Align::Center,"Back");
MyGUI::ImageBox* child2=aaa->createWidget<MyGUI::ImageBox>("ImageBox",0,0,50,50,MyGUI::Align::Center);
child2->setImageTexture("ItemBox.png");
child2->setImageCoord(MyGUI::IntCoord(81,106,50,50));
after create aaa and bbb;
in my frameRenderingQueued event:
aaa->setImageTexture("Cloth1.jpg"); //set a texture
bbb->setImageTexture("Cloth1.jpg"); //set a texture
please wait a minutes . it cost 1GB Memory... why???? i cann't find any reseason.
i hope you can try.. thanks in advans.
i am use MYGUI 3.2.0.
please try it . i project have difficult now.
1302769950
20-10-2012 10:07:47
my.name
20-10-2012 10:50:36
please wait =)
my.name
20-10-2012 10:54:32
aaa and bbb create every frame, but not deleted.
1302769950
20-10-2012 11:25:21
aaa and bbb create every frame, but not deleted.
no. aaa bbb not create in frameevent.
aaa bbb create in createscenen. not frameevent.
frameevent just have
bool MYGUITest::frameEnded( const Ogre::FrameEvent& evt )
{
BaseApplication::frameEnded(evt);
aaa->setImageTexture("Cloth1.jpg");
bbb->setImageTexture("Cloth1.jpg");
return true;
}
aaa bbb just create once....
please test . this real a bug...
thanks my friend.
1302769950
20-10-2012 11:35:08
my.name .
please test. i test many times. aways
this has memory leak...
In fact this problems was find when i use itembox.
in my frameevent.
void MYItemBox::Updata( Ogre::Real PassTime )// MYItemBox is inherit from MYGUI::Itembox
{
for (int i=0;i<getItemCount();i++)
{
MYItemBox::itemInfo* curItemInfo=*getItemDataAt<MYItemBox::itemInfo*>(i);
if (curItemInfo->ItemFlag==ItemBox_None)
{
continue;
}
curItemInfo->updata(PassTime);
setItemDataAt(i,curItemInfo); //here will callback drawitem Event.
//setItemDataAtindex(i,curItemInfo);
}
}
this drawitemEvent
void MYItemBox::ItemBoxDrawItem( MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info )
{
cellview* curCellview=*_item->getUserData<cellview*>();
itemInfo* curIteminfo=*_sender->getItemDataAt<itemInfo*>(_info.index);
//here has memory leak
curCellview->imageboxItem->setImageTexture(curIteminfo->textureName);
}
1302769950
20-10-2012 11:39:23
my.name .
please test. i test many times. aways
this has memory leak...
In fact this problems was find when i use itembox.
in my frameevent.
void MYItemBox::Updata( Ogre::Real PassTime )// MYItemBox is inherit from MYGUI::Itembox
{
for (int i=0;i<getItemCount();i++)
{
MYItemBox::itemInfo* curItemInfo=*getItemDataAt<MYItemBox::itemInfo*>(i);
if (curItemInfo->ItemFlag==ItemBox_None)
{
continue;
}
curItemInfo->updata(PassTime);
setItemDataAt(i,curItemInfo); //here will callback drawitem Event.
//setItemDataAtindex(i,curItemInfo);
}
}
this drawitemEvent
void MYItemBox::ItemBoxDrawItem( MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info )
{
cellview* curCellview=*_item->getUserData<cellview*>();
itemInfo* curIteminfo=*_sender->getItemDataAt<itemInfo*>(_info.index);
//here has memory leak
curCellview->imageboxItem->setImageTexture(curIteminfo->textureName);
}
1302769950
20-10-2012 11:45:59
here is my cellview:
class cellview
{
public:
cellview(MyGUI::Widget* _item,MyGUI::IntSize itemSize,Ogre::String& backgroupname)
{
itemboxBackgroup=_item->createWidget<MyGUI::ImageBox>("ImageBox",0,0,itemSize.width,itemSize.height,MyGUI::Align::Center);
itemboxBackgroup->setItemResource("XinbaoImageSet");
itemboxBackgroup->setItemGroup(backgroupname);
itemboxBackgroup->setItemName("normal");
imageboxborder=itemboxBackgroup
->createWidget<CommonBorder>("CommonBorder",0,0,itemSize.width,itemSize.height,MyGUI::Align::Center);
MyGUI::IntSize itemBoxBordersize=imageboxborder->getSize();
imageboxItem=imageboxborder->createWidget<MyGUI::ImageBox>("ImageBox",1,1,itemBoxBordersize.width-2,itemBoxBordersize.height-2,MyGUI::Align::Center);
CDImageBox=itemboxBackgroup->createWidget<MyGUI::ImageBox>("ImageBox",0,0,itemSize.width,itemSize.height,MyGUI::Align::Center);
CDImageBox->setImageTexture("ItemBox.png");
CDImageBox->setImageCoord(MyGUI::IntCoord(81,106,50,50));
MyGUI::IntSize newImageBoxSize=imageboxItem->getSize();
textbox=imageboxItem->createWidget<MyGUI::TextBox>("TextBox",
newImageBoxSize.width-20,newImageBoxSize.height-16,21,17,
MyGUI::Align::Right|MyGUI::Align::Bottom);
textbox->setTextColour(MyGUI::Colour(1,1,1));
textbox->setTextAlign(MyGUI::Align::Right|MyGUI::Align::Bottom);
itemboxBackgroup->setNeedKeyFocus(false);
itemboxBackgroup->setNeedMouseFocus(false);
CDImageBox->setNeedKeyFocus(false);
CDImageBox->setNeedMouseFocus(false);
};
MyGUI::ImageBox* itemboxBackgroup;
CommonBorder* imageboxborder;
MyGUI::ImageBox* imageboxItem;
MyGUI::TextBox* textbox;
MyGUI::ImageBox* CDImageBox;
};
my.name
20-10-2012 16:12:45
Check in CMake memory leak test.
Start and stop programm.
Check output window in Visual Studio.
1302769950
21-10-2012 01:17:54
my.name please just test once.. i cann't find where has memory leak.
test very sample.
in createscene function ceate aaa and bbb
void MYGUITest::createScene(void)
{
aaa=MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("ImageBox",300,300,50,50,MyGUI::Align::Center,"Back");
//must add a child imagebox. aaa should have a child imagebox
MyGUI::ImageBox* child1=aaa->createWidget<MyGUI::ImageBox>("ImageBox",0,0,50,50,MyGUI::Align::Center);
child1->setImageTexture("ItemBox.png");
child1->setImageCoord(MyGUI::IntCoord(81,106,50,50));
//create bbb and create a child imagebox.bbb=MyGUI::Gui::getInstancePtr()->createWidget<MyGUI::ImageBox>("ImageBox",300,300,50,50,MyGUI::Align::Center,"Back");
//must add a child imagebox. bbb should have a child imagebox
MyGUI::ImageBox* child2=aaa->createWidget<MyGUI::ImageBox>("ImageBox",0,0,50,50,MyGUI::Align::Center);
child2->setImageTexture("ItemBox.png");
child2->setImageCoord(MyGUI::IntCoord(81,106,50,50));
}
and in frame event
bool MYGUITest::frameEnded( const Ogre::FrameEvent& evt )
{
aaa->setImageTexture("Cloth1.jpg");
bbb->setImageTexture("Cloth1.jpg");
return true;
}
you can look memory . a minutes will cost 1GB Memory..
i debug in visual studio find aways new memory in:
/// in MyGUI_OgreRenderManager.cpp
IVertexBuffer* OgreRenderManager::createVertexBuffer()
{
return new OgreVertexBuffer(); // why aways new vertexbuffer in here????
}
please just test... thansk my firend.
Altren
21-10-2012 18:44:33
Please be a little bit more patient and do not post duplicate posts if different threads, and also do not post messages with smiles only. I removed most such posts.
I failed to reproduce your problem yesterday, but now I confirm, that there is something wrong with memory usage. Pointers are not lost, and there is no leaks after MyGUI shutdown though.
I'll look further into it tomorrow.
xfxsworld
10-12-2012 09:09:46
hi, i have the same problem in my project. mygui will create many RenderItem object inner when you changed texture of imagebox frequently. those RenderItem takes a lot of memory, and will be free until you destroy LayerNode. so i think this is not memory leaks, this is a problem of design. please look my post
http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=29338
arong2100
04-01-2013 05:53:49
i have the same problem in my project