GetFieldValue(index, value),需要释放value吗?

我使用TeeChart,先从数据库调数据,然后将数据描点画出曲线,

碰到的问题是: 程序运行后,时间越长 CPU占用率越高,我怀疑是内存泄漏,

由于CPU占用率是随时间增长的, 怀疑是不是这一块代码有问题,value是指针类型,存在泄漏吗?

                if (dataAccess.SearchData(bridgeSn, inverterSn, strTempSt, strTempEnd))

{

CRecordset& rs = dataAccess.GetRecordset();

CString value;

while (!rs.IsEOF())

{

for (int i = 0; i < sizeof(fieldName) / sizeof(char*); ++i)

{

short index = rs.GetFieldIndexByName(fieldName[i]);

rs.GetFieldValue(index, value);

double douValue = atof(value.GetBuffer()); //CString 强转成 double

switch (i)

{

case 2:

((CSeries)m_chart1.Series(nline0)).AddXY(s_x, douValue, nowTime, RGB(0, 0, 0));

m++;

printf("描点次数为:%d \n", m);

break;

case 3:

((CSeries)m_chart1.Series(nline1)).AddXY(s_x, douValue, nowTime, RGB(255, 0, 0));

//printf("记录的直流电压为:%lf \n", douValue);

break;

case 4:

((CSeries)m_chart1.Series(nline2)).AddXY(s_x, douValue, nowTime, RGB(46, 139, 87));

//printf("记录的频率为:%lf \n", douValue);

break;

case 5:

((CSeries)m_chart1.Series(nline3)).AddXY(s_x, douValue, nowTime, RGB(0, 0, 255));

//printf("记录的功率为:%lf \n", douValue);

break;

case 6:

((CSeries)m_chart1.Series(nline4)).AddXY(s_x, douValue, nowTime, RGB(205, 92, 92));

//printf("记录的电量为:%lf \n", douValue);

break;

case 7:

((CSeries)m_chart1.Series(nline5)).AddXY(s_x, douValue, nowTime, RGB(255, 185, 15));

//printf("记录的温度为:%lf \n", douValue);

break;

default:

break;

}

Sleep(100);

}

s_x += 1.0;

rs.MoveNext();

Sleep(200);

}

rs.Close();

//delete value;

}

}

}

break;

delete miData;

回答

不是value问题,m_chart1.Series(nline0)).AddXY()一直在增加数据到图表中,内存自然往上走。

以上是 GetFieldValue(index, value),需要释放value吗? 的全部内容, 来源链接: www.h5w3.com/37617.html

回到顶部