Not at all an expert in MFC, but I have been put on a project to revamp the GUI in one of our applications. I am building a dialog with a CListCtrl and seeing memory issues, even though the list I am displaying will contain usually no more than about 200 rows. There are 4 columns, and I'm attaching an associated int value with each row using SetItemData in order to do filtering.
When I filter, I repopulate the list by first calling DeleteAllItems() and then looping to populate with only the data that passes my filter. When I watch in the Performance tab in the system Task Manager dialog, I see memory taken up when the dialog opens. Seems like more than I would imagine, but anyway. When I filter, if nothing is shown as a result of the chosen filter, the memory is never reclaimed by the system, according to Task Manager Performance tab. When I change the filter to show some rows, I see more memory taken. I never see memory given back to the system. If I continue to filter, I will eventually see the memory usage go almost to full usage, and I will get an Out of memory dialog that MFC puts up.
I have seen this out of memory dialog also when I am just scrolling up and down a lot in a full (unfiltered) view of the data. For each scrolling, the list control is somewhat slow to repaint, and the memory usage in the Performance tab goes up, even though I'm not adding any data.
Does anyone have a feeling for what might be going on here? I'm stumped at the moment. The following is basically what I'm doing in my code. I am not otherwise managing the view:
m_ListCtrl.DeleteAllItems();
for (int i=0; i<mylist.size(); i++)
{
// here I get all the data from the current record in mylist, one of them being an int value iSecs.
...
// insert data item
int row = m_ListCtrl.InsertItem(i, sTimeStamp.c_str());
BOOL ok = m_ListCtrl.SetItem(i, 1, sErrorCode.c_str());
ok = m_ListCtrl.SetItem(i, 2, sErrorLevel.c_str());
ok = m_ListCtrl.SetItem(i, 3, sDescription.c_str());
// set the timestamp seconds as item data for later filtering for display
ok = m_ListCtrl.SetItemData(row, (DWORD_PTR)iSecs);
}