|
memory increase problem |
Posted by Lim Bo Young on Aug-16-2018 09:14 |
|
Simple code. If it repeats continuously, memory increase occurs.
Version used the latest version of 6.0.5. (MFC C ++) (timer is calling in 100ms)
SurfaceChart * pclsSurfaceChart = new SurfaceChart (500, 400);
delete pclsSurfaceChart;
pclsSurfaceChart = NULL;
Memory in Task Manager at first start is 23,996K
The memory for the intermediate check is 42,408K.
It is continuously increasing. It is going over 10 minutes, and the more it repeats, the more it increases indefinitely.
Please confirm.
|
Re: memory increase problem |
Posted by Peter Kwan on Aug-16-2018 13:11 |
|
Hi Lim,
I have just tested, but in my testing, I cannot find any memory leak.
I tried the following code, which executes every 10ms for 100000 times, and there is no leak.
#include "chartdir.h"
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
for (int i = 0; i < 10000; ++i)
{
if (i % 100 == 0)
printf(".");
SurfaceChart * pclsSurfaceChart = new SurfaceChart(500, 400);
delete pclsSurfaceChart;
pclsSurfaceChart = NULL;
Sleep(10);
}
return 0;
}
I also tried to start from the original "realtimedemo" sample project. I change the timer to 50ms, and added 3 lines of code at the top of the "drawChart" routine:
SurfaceChart * pclsSurfaceChart = new SurfaceChart(500, 400);
delete pclsSurfaceChart;
pclsSurfaceChart = NULL;
Then I ran the code, and there is no memory leak.
I have attached my modified "realtimedemo" MFC sample project for your reference. To try it, please unzip it and copy the "realtimedemo" subdirectory into the "ChartDirector/mfcdemo" subdirectory, replacing the existing "realtimedemo". Then you can open the "mfcdemo.sln" solution, set "realtimedemo" as the start up project, and run and try it.
If the above still cannot solve the problem, is it possible to provide a complete project (may be you can modify my sample project) that can reproduce the problem, so I can try it?
Alternatively, may be you can try to replace:
SurfaceChart * pclsSurfaceChart = new SurfaceChart (500, 400);
delete pclsSurfaceChart;
pclsSurfaceChart = NULL;
to:
SurfaceChart * pclsSurfaceChart = NULL;
and check if there are still a memory leak.
Regards
Peter Kwan
|
|