Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Chart Control
  New Posts New Posts RSS Feed - CXTPChartSeriesPoint
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPChartSeriesPoint

 Post Reply Post Reply
Author
Message
kunishima View Drop Down
Newbie
Newbie
Avatar

Joined: 17 November 2019
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote kunishima Quote  Post ReplyReply Direct Link To This Post Topic: CXTPChartSeriesPoint
    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)
}
}



Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 291
Post Options Post Options   Thanks (2) Thanks(2)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.