Hi,
I noticed something about listbox. When you delete a listbox or an item of it, not all the memory it was using is released.
For example,
-if i create a listbox without any item, my window use 460 bytes
-if i create a listbox with 1000 items, my window use 41248 bytes
-now if i delete the 1000 items that i just created, my window use 8264 bytes
I don't know if it's a normal behavior or there is a problem ? but i think after deleting all the items, my window should go back to only using 460 bytes.
With code below you can reproduce the problem i faced.
I noticed something about listbox. When you delete a listbox or an item of it, not all the memory it was using is released.
For example,
-if i create a listbox without any item, my window use 460 bytes
-if i create a listbox with 1000 items, my window use 41248 bytes
-now if i delete the 1000 items that i just created, my window use 8264 bytes
I don't know if it's a normal behavior or there is a problem ? but i think after deleting all the items, my window should go back to only using 460 bytes.
With code below you can reproduce the problem i faced.
You'll find also attached a screenshot from emWinSpy when you can see clearly when a listbox is deleted not all the memory it was using is freed.#include "GUI.h"
#include "DIALOG.h"
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_LISTBOX_0 (GUI_ID_USER + 0x01)
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aHistoricDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 240, 274 },
{ LISTBOX_CreateIndirect, 0, ID_LISTBOX_0, 5, 35, 235, 192, 0, 100 },
};
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
for (int i = 0; i < 1000; ++i) {
LISTBOX_AddString(hItem, "25");
}
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
case GUI_KEY_ENTER:
GUI_EndDialog(pMsg->hWinSrc, 0);
//WM_DeleteWindow(pMsg->hWin); //even with DeletWindow function, i get the same result
break;
default:
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Init();
GUI_Clear();
GUI_CreateDialogBox(_aHistoricDialogCreate, GUI_COUNTOF(_aHistoricDialogCreate), _cbDialog, WM_HBKWIN, 0, 24);
while (1) {
GUI_Delay(100);
};
}
/*************************** End of file ****************************/