David Campeau
March 31st, 1999, 01:55 PM
Hi,
I have a problem in my code. If I run the Task Manager when my program is running, I can see clearly that I have a
memory problem. When ever OnUpdate
EditPaste is executed the memory grow's by about 4Kb. I can make it grow to 5Mb in under a minute!
Thanks in advance
David Campeau
void CDLabView::OnUpdateEditPaste( CCmdUI* pCmdUI )
{//test if it's a valid clipboard format and valid data for the selection
COleDataObject* obj = new COleDataObject();
pCmdUI->Enable(TestClipboardIntern(obj));
delete obj;
}
bool CDLabView::TestClipboardIntern(COleDataObject* obj)
{
if( obj->AttachClipboard())
{
//DLAB_CF_PRIVATE_FIRST was register with
//DLAB_CF_PRIVATE_FIRST = ::RegisterClipboardFormat(_T("DLAB1"));
if( obj->IsDataAvailable( DLAB_CF_PRIVATE_FIRST ))
{// If this block is commented there is no more memory problem
HGLOBAL hmem = obj->GetGlobalData( DLAB_CF_PRIVATE_FIRST );
CMemFile sf(( BYTE* )::GlobalLock( hmem ), ::GlobalSize( hmem ));
CArchive ar( &sf, CArchive::load );
//test if data is valid
bool bResult = ValidateArchive(ar);
ar.Close();
::GlobalUnlock( hmem );
//::GlobalFree( hmem ); // never return NULL
return bResult;
}
}
return false;
}
I have a problem in my code. If I run the Task Manager when my program is running, I can see clearly that I have a
memory problem. When ever OnUpdate
EditPaste is executed the memory grow's by about 4Kb. I can make it grow to 5Mb in under a minute!
Thanks in advance
David Campeau
void CDLabView::OnUpdateEditPaste( CCmdUI* pCmdUI )
{//test if it's a valid clipboard format and valid data for the selection
COleDataObject* obj = new COleDataObject();
pCmdUI->Enable(TestClipboardIntern(obj));
delete obj;
}
bool CDLabView::TestClipboardIntern(COleDataObject* obj)
{
if( obj->AttachClipboard())
{
//DLAB_CF_PRIVATE_FIRST was register with
//DLAB_CF_PRIVATE_FIRST = ::RegisterClipboardFormat(_T("DLAB1"));
if( obj->IsDataAvailable( DLAB_CF_PRIVATE_FIRST ))
{// If this block is commented there is no more memory problem
HGLOBAL hmem = obj->GetGlobalData( DLAB_CF_PRIVATE_FIRST );
CMemFile sf(( BYTE* )::GlobalLock( hmem ), ::GlobalSize( hmem ));
CArchive ar( &sf, CArchive::load );
//test if data is valid
bool bResult = ValidateArchive(ar);
ar.Close();
::GlobalUnlock( hmem );
//::GlobalFree( hmem ); // never return NULL
return bResult;
}
}
return false;
}