Print Page | Close Window

CXTPChartSeriesPoint

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Chart Control
Forum Description: Topics Related to Codejock Chart Control
URL: http://forum.codejock.com/forum_posts.asp?TID=23923
Printed Date: 03 December 2024 at 1:08pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPChartSeriesPoint
Posted By: kunishima
Subject: CXTPChartSeriesPoint
Date Posted: 17 November 2019 at 9:06pm
Hi,

I am facing the following problem related to memory allocation and deallocation:

CryXtreme 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)
}
}






Replies:
Posted By: agontarenko
Date Posted: 25 November 2019 at 4:01am
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net