Hi everyone.
I am using Qt 4.4.3 embedded to write a GUI on ubuntu .
It consists in a main menu with 8 icons, and each of them leads to another menu.
In order to use as few Ram memory as possible, I coded my application so that when I am entering a menu, I use " new" to allocate memory to this menu and use "delete" to come back to the main menu.
To give an exemple, if I want to go from the "main menu" to the "configuration menu":
in mainmenu.cpp:
(ConfigationMenu is declared in mainmenu.h)
(These slots respond to clicked() signals from mainmenu and ConfigurationMenu)
/**********SLOTS******/
void mainmenu::toConfigurationMenu()
{
win_ConfigurationMenu=new ConfigurationMenu(this);
.....
}
void mainmenu::backToConfigurationMenu()
{
delete(ConfigurationMenu);
....
}
I thought this code would free the memory allocated by theConfigurationMenu object but when I am displaying the amount of memory my program is using while running ( using the command ps on my process id ), I can the memory is not desallocatted.
Actually after investigation, I discovered that when I create a submenu object, memory is allocated but never desallocated. However it is not a leak because if I enter again in this submenu, memory usage does not change.
In addition if I entered submenu1 befor and enter submenu2, memory allocated for submenu1 ( wich, to me, if not desallocated should at least be writable again by another object ) is not written by the data of my submenu2 object.
Which means in conclusion: if I enter at least one time in all my submenus, the memory usage is the same of the one that would be used if create all my submenu objects in the constructor of mainmenu when the program is launched.
Is this comportment usual? Would it be possible to "really" desallocate memory when I delete an object?
Thanks for your help!
Regards.
Bookmarks