ccnuxjg 2002年11月21日
win2000正常,98里面系统资源泄漏,急!!!!!
此函数在2000和XP下面运行一切正常。但是在WIN98下面就会如下现象:

在OnTimer里面调用此函数(每隔一秒调用一次),大约过几分钟之后,整个系统就会慢起来。首先,图形绘制不出来,然后整个WINDOWS的重绘机制都好像失效。

可是我却找不到有什么资源泄漏的地方。经过反复测试,发现问题不可能发生在别的地方。 烦闹各位大仙帮帮忙!!!!

void DrawGraphyClass::DrawGraphy ( CDC *pDC, const int _InputRate )
{
CDC MemDC;
CBitmap MemBitmap;

MemDC.CreateCompatibleDC ( NULL );
MemBitmap.CreateCompatibleBitmap ( pDC, m_DisplayRect.right - m_DisplayRect.left, m_DisplayRect.bottom - m_DisplayRect.top );

CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);

MemDC.FillSolidRect (0, 0, m_DisplayRect.right - m_DisplayRect.left, m_DisplayRect.bottom - m_DisplayRect.top, RGB(0, 0, 0));
CPen pen;
CPen *OldPen;
pen.CreatePen(PS_SOLID, 1, m_GridColor );
OldPen=MemDC.SelectObject(&pen);

static int count = 0;

count ++;

int _Interval = m_nInterval / m_nTimes; //ÿÒƶ¯Ò»´ÎµÄ¾àÀë

for ( int i = 1; i <= m_nHorNum; i++ )
{
MemDC.MoveTo ( 0, i * m_nInterval );
MemDC.LineTo ( m_DisplayRect.right - m_DisplayRect.left, i * m_nInterval );
}
for ( int j = 1; j <= m_nColNum; j++ )
{
count = count % m_nTimes;
MemDC.MoveTo ( j * m_nInterval - count * _Interval, 0 );
MemDC.LineTo ( j * m_nInterval - count * _Interval, m_DisplayRect.bottom - m_DisplayRect.top );
}

MemDC.SelectObject(&OldPen);
pen.DeleteObject();

pen.CreatePen (PS_SOLID, 1, m_LineColor );
OldPen = MemDC.SelectObject ( &pen );

float _fTempInterval = static_cast<float> ( m_DisplayRect.bottom - m_DisplayRect.top ) / 100 ;
int _yPos = static_cast<int> ( m_DisplayRect.bottom - m_DisplayRect.top - _InputRate * _fTempInterval + 0.5 );

std::list<CPoint>::iterator it;

if ( m_PointList.size() < m_nTotalNum )
{
m_PointList.push_back ( CPoint ( m_DisplayRect.right - m_DisplayRect.left, _yPos ) );
}
else
{
m_PointList.push_back ( CPoint ( m_DisplayRect.right - m_DisplayRect.left, _yPos ) );
m_PointList.pop_front ();
}
for ( it = m_PointList.end(); it != m_PointList.begin(); it-- )
{
it->x = it->x - _Interval;
}
it->x = it->x - _Interval;
int n=0;
for ( it = m_PointList.end(), n=0, it--; it != m_PointList.begin() && n<= m_PointList.size(); it--, n++ )
{
CPoint _tempPoint = *it;
CPoint _TempPoint = *--it;
it++;
MemDC.MoveTo ( _tempPoint );
MemDC.LineTo ( _TempPoint );
}


pDC->BitBlt ( m_DisplayRect.left, m_DisplayRect.top, m_DisplayRect.right-m_DisplayRect.left, m_DisplayRect.bottom-m_DisplayRect.top, &MemDC, 0, 0, SRCCOPY );

MemDC.SelectObject(&OldPen);
pen.DeleteObject();

MemBitmap.DeleteObject();
MemDC.DeleteDC();

}


实在是不解!
...全文
11 点赞 收藏 34
写回复
34 条回复

还没有回复,快来抢沙发~

发动态
发帖子
VC/MFC
创建于2007-09-28

7875

社区成员

42.1w+

社区内容

VC/MFC相关问题讨论
社区公告
暂无公告