Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Memory requirement in CListCtrl

Memory requirement in CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rbbhosale
    wrote on last edited by
    #1

    The following is my code for the listctrl ///////////////////////////////////////////////////////////// lvItem.iImage = m_nIcon; for (int i = 0; i<200;i++) { nChk ++; szTest.Format("%d",nChk); m_test = szTest; UpdateData(FALSE); // Set up item lvItem.mask = LVIF_TEXT | LVIF_IMAGE; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = LPTSTR(LPCTSTR(szTest)); m_List.InsertItem (&lvItem); // Set up time and date CString szTimeDate = timeTimeStamp.Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT); int nIndex = szTimeDate.Find(" "); CString szTime = szTimeDate.Right(szTimeDate.GetLength() - nIndex - 1); CString szDate = szTimeDate.Left(nIndex); nListCount = m_List.GetItemCount(); if(nListCount >1000) m_List.DeleteItem (nListCount-1); nListCount = m_List.GetItemCount(); // Insert Subitem in list control (date) lvItem.mask = LVIF_TEXT; lvItem.iSubItem = 1; // SubItem 1 is Date column lvItem.pszText = LPTSTR(LPCTSTR(szDate)); m_List.SetItem(&lvItem); // Insert Subitem in list control (time) lvItem.iSubItem = 2; // SubItem 2 is Time column lvItem.pszText = LPTSTR(LPCTSTR(szTime)); m_List.SetItem(&lvItem); } /////////////////////////////////////////////////////////// What I find is that the memory requirement increases as I increase the items but as u can see I am removing the items from the List after the max. no of items is reached still I find a large chunk of memory being taken up. The memory requirement for say 1000 items is 2964K then it should remain the same as I am deleting the extra items. How can I control this memory requirement.? Rohan

    N D 2 Replies Last reply
    0
    • R rbbhosale

      The following is my code for the listctrl ///////////////////////////////////////////////////////////// lvItem.iImage = m_nIcon; for (int i = 0; i<200;i++) { nChk ++; szTest.Format("%d",nChk); m_test = szTest; UpdateData(FALSE); // Set up item lvItem.mask = LVIF_TEXT | LVIF_IMAGE; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = LPTSTR(LPCTSTR(szTest)); m_List.InsertItem (&lvItem); // Set up time and date CString szTimeDate = timeTimeStamp.Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT); int nIndex = szTimeDate.Find(" "); CString szTime = szTimeDate.Right(szTimeDate.GetLength() - nIndex - 1); CString szDate = szTimeDate.Left(nIndex); nListCount = m_List.GetItemCount(); if(nListCount >1000) m_List.DeleteItem (nListCount-1); nListCount = m_List.GetItemCount(); // Insert Subitem in list control (date) lvItem.mask = LVIF_TEXT; lvItem.iSubItem = 1; // SubItem 1 is Date column lvItem.pszText = LPTSTR(LPCTSTR(szDate)); m_List.SetItem(&lvItem); // Insert Subitem in list control (time) lvItem.iSubItem = 2; // SubItem 2 is Time column lvItem.pszText = LPTSTR(LPCTSTR(szTime)); m_List.SetItem(&lvItem); } /////////////////////////////////////////////////////////// What I find is that the memory requirement increases as I increase the items but as u can see I am removing the items from the List after the max. no of items is reached still I find a large chunk of memory being taken up. The memory requirement for say 1000 items is 2964K then it should remain the same as I am deleting the extra items. How can I control this memory requirement.? Rohan

      N Offline
      N Offline
      Neagoe Gabriel
      wrote on last edited by
      #2

      Make a virtual list... NG

      1 Reply Last reply
      0
      • R rbbhosale

        The following is my code for the listctrl ///////////////////////////////////////////////////////////// lvItem.iImage = m_nIcon; for (int i = 0; i<200;i++) { nChk ++; szTest.Format("%d",nChk); m_test = szTest; UpdateData(FALSE); // Set up item lvItem.mask = LVIF_TEXT | LVIF_IMAGE; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = LPTSTR(LPCTSTR(szTest)); m_List.InsertItem (&lvItem); // Set up time and date CString szTimeDate = timeTimeStamp.Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT); int nIndex = szTimeDate.Find(" "); CString szTime = szTimeDate.Right(szTimeDate.GetLength() - nIndex - 1); CString szDate = szTimeDate.Left(nIndex); nListCount = m_List.GetItemCount(); if(nListCount >1000) m_List.DeleteItem (nListCount-1); nListCount = m_List.GetItemCount(); // Insert Subitem in list control (date) lvItem.mask = LVIF_TEXT; lvItem.iSubItem = 1; // SubItem 1 is Date column lvItem.pszText = LPTSTR(LPCTSTR(szDate)); m_List.SetItem(&lvItem); // Insert Subitem in list control (time) lvItem.iSubItem = 2; // SubItem 2 is Time column lvItem.pszText = LPTSTR(LPCTSTR(szTime)); m_List.SetItem(&lvItem); } /////////////////////////////////////////////////////////// What I find is that the memory requirement increases as I increase the items but as u can see I am removing the items from the List after the max. no of items is reached still I find a large chunk of memory being taken up. The memory requirement for say 1000 items is 2964K then it should remain the same as I am deleting the extra items. How can I control this memory requirement.? Rohan

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        You are assuming that deleting an item from a list control, or freeing memory in general, automatically lowers your application's memory footprint. That is wrong. While freed memory does eventually make its way back to the available pool, Task Manager will show you what is effectively a high-water mark. In other words, just because you do not see it go down does not necessarily mean there is a problem.


        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

        R 1 Reply Last reply
        0
        • D David Crow

          You are assuming that deleting an item from a list control, or freeing memory in general, automatically lowers your application's memory footprint. That is wrong. While freed memory does eventually make its way back to the available pool, Task Manager will show you what is effectively a high-water mark. In other words, just because you do not see it go down does not necessarily mean there is a problem.


          "One must learn from the bite of the fire to leave it alone." - Native American Proverb

          R Offline
          R Offline
          rbbhosale
          wrote on last edited by
          #4

          How do I check that the memory requirement for the EXE is within permissible limits.Since the action atleast indicates an increase in memory usage by the EXE. As you say the Task Manager is not the true picture, but the memory usage shown in the same is certainly increasing.How do I solve that.

          D 1 Reply Last reply
          0
          • R rbbhosale

            How do I check that the memory requirement for the EXE is within permissible limits.Since the action atleast indicates an increase in memory usage by the EXE. As you say the Task Manager is not the true picture, but the memory usage shown in the same is certainly increasing.How do I solve that.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            I'm not exactly sure what you are asking, but it sounds like you need to run your program trhrough all of the possible combinations, and then note the memory consumption via Task Manager right before you shut it down. That might give you a good-enough answer to the question, "In the worst case, how much memory does my program require to run?"


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups