|
Hi. about memory and gpi leak |
Posted by Ji-hyeon Choi on Jun-26-2024 18:53 |
|
I hope this message finds you well.
After upgrading our library from version 5.0 to 7.0, we have encountered issues related to memory and GDI leaks. Upon investigation, we discovered that the problem is caused by the accumulation of m_currentHBITMAP in the CStaticHelper() class.
The CStaticHelper() class lacked a destructor, which led to these leaks. By adding a destructor and incorporating the following code, we were able to resolve the issue:
CStaticHelper::~CStaticHelper()
{
if (0 != m_currentHBITMAP)
{
DeleteObject(m_currentHBITMAP);
m_currentHBITMAP = 0;
}
}
Please let us know if you require any further details or assistance regarding this issue.
Best regards, |
Re: Hi. about memory and gpi leak |
Posted by Peter Kwan on Jun-27-2024 02:20 |
|
Hi Ji-hyeon Choi,
Sorry for this problem. I confirm there is a memory/resource leak in the CChartViewer.
When the CChartViewer is destroyed, we should call displayChart(0) to clear the resource:
void CChartViewer::OnDestroy()
{
setViewPortControl(0);
delete m_hotSpotTester;
m_hotSpotTester = 0;
delete m_delayedChart;
m_delayedChart = 0;
delete m_imageMapChart;
m_imageMapChart = 0;
// *** Should call displayChart(0) here ***
displayChart(0);
CStatic::OnDestroy();
}
In our code, we put displayChart(0) in the CViewPortControl::OnDestroy, but not CChartViewer::OnDestroy, and it results in the memory/resource leak in CChartViewer. Your method to add a destructor can also fix the problem.
We will update the ChartDirector for C++ release to incorporate the fix.
Best Regards
Peter Kwan |
|