Memdev deallocate memory

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Memdev deallocate memory


      I am using below routines to initialize the knob using memory device. The knob and related functionality working as expected. I am using a knob on two different screens and switching in between. While switching between the screens, I have observed in task manager that the memory is increasing when switched between the screens and it is around 0.2-0.3 MB memory per iteration.
      It seems like the issue is related to memory device only. I am trying to delete the memory using GUI_MEMDEV_Delete(handle) but I am getting an exception for this routine.
      If this issue is related to the memory device and deallocating the memory will be the solution then could you please let me know how and where to de-allocate the memory?

      Source Code

      1. WM_INIT_DIALOG:
      2. // Here knob is initialized using below routines.
      3. WM_GetDialogItem(handle, id);
      4. handle = GUI_MEMDEV_CreateFixed32(x0, y0, xSize, ySize);
      5. GUI_MEMDEV_Select(handle)
      6. GUI_SetBkColor(color);
      7. GUI_Clear();
      8. GUI_DrawBitmap(pBM, x0, y0);
      9. GUI_MEMDEV_Select(LCD);
      10. KNOB_SetDevice(handle, MemdevHandle);
      11. KNOB_SetRange(handle, minRange, maxRange);
      12. KNOB_SetOffset(handle, offset);
      13. //GUI_MEMDEV_Delete(handle)
      15. //Here knob is updated/rotated.
      Display All
    • Hi,

      you have to save the KNOB handle in your "handle" variable, not a memory device handle. You should use the KNOB handle for any KNOB-prefixed routines and the memory device handle for MEMDEV routines.

      Regarding line 9: When you are done drawing in a memory device, you should de-select it using GUI_MEMDEV_Select(0).

      When you are using the correct handles, no exception should occur. By the way: while the KNOB is in use, you should not delete the memory device. You should instead delete it when the window is deleted (case WM_DELETE).

      Best regards,