CXTPChartSeriesPoint |
Post Reply |
Author | |
kunishima
Newbie Joined: 17 November 2019 Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 17 November 2019 at 9:06pm |
Hi,
I am facing the following problem related to memory allocation and deallocation: Xtreme ToolkitPro v15.3.1 I have allocated a number of CXTPChartSeriesPoint instances on the chart using CXTPChartFastLineSeriesStyle. After processing, I have called the RemoveAll() function for the class CXTPChartSeriesCollection. I am expecting that the memory allocated earlier will be deallocated and the free space in the user space (the amount of memory available to the process) will recover after calling RemoveAll() function, but it does not. Eventually, the process runs out of memory. Could anyone please help me with this issue? Here my code: void CFastLineView::AddPoint() { CXTPChartContent* pContent = m_wndChartControl.GetContent(); CXTPChartSeriesCollection* pCollection = pContent->GetSeries(); int nCount; if (pCollection) { for (int s = 0; s < pCollection->GetCount(); s++) { CXTPChartSeries* pSeries = pCollection->GetAt(s); if (pSeries) { int nValue = 50; nCount = pSeries->GetPoints()->GetCount(); if (nCount) nValue = (int)pSeries->GetPoints()->GetAt(nCount - 1)->GetValue(0); nValue = nValue + (rand() % 20) - 10; if (nValue < 0) nValue = 0; if (nValue > 100) nValue = 100; pSeries->GetPoints()->Add(new CXTPChartSeriesPoint(nCount, nValue)); } } } CXTPChartDiagram2D* pDiagram = DYNAMIC_DOWNCAST(CXTPChartDiagram2D, m_wndChartControl.GetContent()->GetPanels()->GetAt(0)); ASSERT (pDiagram); if (nCount > 100) { CXTPChartAxisRange* pRange = pDiagram->GetAxisX()->GetRange(); BOOL bAutoScroll = pRange->GetViewMaxValue() == pRange->GetMaxValue(); pRange->SetMaxValue(nCount); if (bAutoScroll) { double delta = pRange->GetViewMaxValue() - pRange->GetViewMinValue(); pRange->SetViewAutoRange(FALSE); pRange->SetViewMaxValue(nCount); pRange->SetViewMinValue(nCount - delta); } } } // 1msec Interval void CFastLineView::OnTimer(UINT_PTR nIDEvent) { for (int i = 0; i < 1000; i++){ AddPoint(); } } // Collection, point initialization void CFastLineView::CollectionRemoveAll() { CXTPChartContent* pContent = m_wndChartControl.GetContent(); CXTPChartSeriesCollection* pCollection = pContent->GetSeries(); pCollection->RemoveAll(); } // Event when button is pressed void CFastLineView::OnButton() { CString str; MEMORYSTATUSEX memstat; memstat.dwLength = sizeof(memstat); if (GlobalMemoryStatusEx(&memstat)) { str.Format("%dMB", memstat.ullAvailVirtual/(1024*1024)); AfxMessageBox(str); // Example output: 1000MB } CollectionRemoveAll(); if (GlobalMemoryStatusEx(&memstat)) { str.Format("%dMB", memstat.ullAvailVirtual/(1024*1024)); AfxMessageBox(str); // Example output: 1000MB (memory not recovered) } } |
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 291 |
Post Options
Thanks(2)
|
Hello, I've checked 15.3.1 and 19.1 versions and any problem has not found. If I to call GlobalMemoryStatusEx function in OnInitialUpdate up to initialization, I've got about the same result what after CollectionRemoveAll function call. Thus I think CollectionRemoveAll function call has no effect on MEMORYSTATUSEX::ullAvailVirtual. Regards, Artem Gontarenko
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |