我在一个循环中反复调用CPicture类的一个Load(IStream* pstm)函数用来装载Jpeg图像,然后来显示。循环中的代码片断如下
////////////////////////////////////////////////////////
AcquireWriteLock(&lock);
if (WriteOK(&lock))
{
TRACE("Arrived here!_____");
bIsPicture=Load(pStream);
TRACE("Stopped here!\n");
}
else
{
....
}
ReleaseWriteLock(&lock);
//////////////////////////////////////////////////////
Load(pStream)是一个CPicture类的函数,原型为
BOOL CPicture::Load(IStream* pstm)
{
Free();
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (void**)&m_spIPicture);
if(SUCCEEDED(hr) && m_spIPicture)
{
ASSERT(SUCCEEDED(hr) && m_spIPicture);
return TRUE;
}
else
{
return FALSE;
}
}
这个函数在我循环中执行了大约50000次,死掉了,郁闷啊!不知道该怎么办了!!!高人们给点指导啊,项目快到Deadline了。
////////////////////////////////////////////////////////
AcquireWriteLock(&lock);
if (WriteOK(&lock))
{
TRACE("Arrived here!_____");
bIsPicture=Load(pStream);
TRACE("Stopped here!\n");
}
else
{
....
}
ReleaseWriteLock(&lock);
//////////////////////////////////////////////////////
Load(pStream)是一个CPicture类的函数,原型为
BOOL CPicture::Load(IStream* pstm)
{
Free();
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (void**)&m_spIPicture);
if(SUCCEEDED(hr) && m_spIPicture)
{
ASSERT(SUCCEEDED(hr) && m_spIPicture);
return TRUE;
}
else
{
return FALSE;
}
}
这个函数在我循环中执行了大约50000次,死掉了,郁闷啊!不知道该怎么办了!!!高人们给点指导啊,项目快到Deadline了。
记着给m_spIPicture release
void Free()
{
if (m_spIPicture)
{
m_spIPicture.Release();
}
}
qq:11304309,请指教。
估计是相关的GDI资源出了问题,忘了释放吧?打开任务管理器看看性能栏。
揭帖,多谢!
http://www.lovesnow.com/down/soft.asp?id=8