End Google Ads 201810 - BS.net 01 --> When VC++ "LineTo" statement is called very often (say every 100 ms), it is using more resource and it is not getting released. If my application is running for longer period (say 2 hours), high usage of resource problem causing more RAM usage and memory is not getting released and growing continuously.

Sample code is given below (Please send your personal email id, so that I can email complete code)

//------------------------------------------------------------------

//Callback method creation (100 ms)
m_nEventID = timeSetEvent(100,0,GeneratePeriodicCall,DWORD(this),TIME_PERIODIC);


//callback method
void CALLBACK GeneratePeriodicCall(UINT uID, UINT UMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CTestAppView* pView = (CTestAppView*) dwUser;

//kill thread if active
if(g_hDrawChartThread != INVALID_HANDLE_VALUE)
{
DWORD dwExitCode =NULL;

DWORD dw = NULL;

GetExitCodeThread(g_hDrawChartThread, &dwExitCode);

if(dwExitCode == STILL_ACTIVE)
{
::CloseHandle(g_hDrawChartThread);

g_hDrawChartThread = NULL;
}
else
{
g_hDrawChartThread = NULL;
}
}

//create thread
g_hDrawChartThread = CreateThread(NULL,0,DrawChart,pView,0,0);
}


//Thread call
DWORD __stdcall DrawChart(LPVOID lParam)
{
CTestAppView* pView = (CTestAppView*)lParam;

CClientDC dc(pView);

int nSaveDC = dc.SaveDC();

long x = 0;

long y = 0;

for(long i = 0 ; i < 100000 ;i++)
{
dc.MoveTo(x,y);

//THIS LINE IS CAUSING SERIOUS RESOURCE LEAK
dc.LineTo(x + 1, y + 1);

x = x + 1;

y = y + 1;
}

dc.RestoreDC(nSaveDC);

return 0;
}
//------------------------------------------------------------------

Anyone can clarify me why "LineTo()" is not releasing resources & utilising more RAM. This RAM memory is not getting released until unless I close my VC++ application.

Any solution/hint, welcome.

Thanks in advance,
Madhu