I have been running an application using EMWin for a while. A client discovered that some of the screen elements began disappearing after running for around 2 months. I have isolated this to what appears to be a memory leak in EmWin. I am periodically monitoring the used memory in emwin and printing it out.
I have observed a few things.
1) removing
eliminates the memory leak.
2) removing
also eliminates the memory leak.
Any thoughts on this would be appreciated. I have attached a good portion of a test main that I have been using. I did not include all of it as it is specific to the custom hardware I am using.
The behavior is as follows:
The memory usage is periodically printed. When either 1) or 2) above are done, the memory usage stabilizes. When they are both present, the memory slowly grows. After a point it grows so large that the elements no longer get drawn on the screen.
I am using emwin v5.32.
Display All
Thanks for the help,
Eddie
I have observed a few things.
1) removing
eliminates the memory leak.
2) removing
also eliminates the memory leak.
Any thoughts on this would be appreciated. I have attached a good portion of a test main that I have been using. I did not include all of it as it is specific to the custom hardware I am using.
The behavior is as follows:
- A button is created with the text "this is a test" with a green background.
- Wait 1 second.
- The button is deleted.
- Wait 1 second.
- Repeat.
The memory usage is periodically printed. When either 1) or 2) above are done, the memory usage stabilizes. When they are both present, the memory slowly grows. After a point it grows so large that the elements no longer get drawn on the screen.
I am using emwin v5.32.
C Source Code
- static void window_callback(WM_MESSAGE* pMsg)
- {
- WM_DefaultProc(pMsg);
- }
- static void button_callback(WM_MESSAGE* pMsg)
- {
- BUTTON_Callback(pMsg);
- }
- static GUI_HWIN _hWnd = 0;
- static BUTTON_Handle checkbox;
- bool window_created = false;
- void CreateWindow()
- {
- _hWnd = WM_CreateWindow(0, 0, 100, 100, WM_CF_MEMDEV|WM_CF_SHOW, window_callback, NULL);
- checkbox = BUTTON_CreateEx(0, 0, 100, 100, _hWnd, WM_CF_MEMDEV|WM_CF_SHOW, 0, widget_id++);
- WM_SetCallback(checkbox, button_callback);
- BUTTON_SetText(checkbox, "this is a test");
- window_created = true;
- }
- void DestroyWindow()
- {
- BUTTON_SetText(checkbox, NULL);
- WM_SetCallback(checkbox, NULL);
- WM_DeleteWindow(_hWnd);
- window_created = false;
- }
- int main()
- {
- // init system
- // init external ram
- // init lcd
- // init touch
- // init emwin
- // init timers
- while(1)
- {
- if(print_timer.read_ms() > 100)
- {
- printf("%ld\r\n", GUI_ALLOC_GetNumUsedBytes());
- print_timer.reset();
- }
- if(change_timer.read_ms() > 1000)
- {
- if(window_created)
- {
- DestroyWindow();
- }
- else
- {
- CreateWindow();
- }
- change_timer.reset();
- }
- // Get touch input
- GUI_TOUCH_StoreStateEx(&_touchState);
- WM_Exec();
- wait_ms(10);
- }
- }
Thanks for the help,
Eddie
The post was edited 2 times, last by eddie.hunckler ().