|
-
March 31st, 1999, 02:55 PM
#1
Memory Problem with COleDataObject
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;
}
-
March 31st, 1999, 03:55 PM
#2
Re: Memory Problem with COleDataObject
Try doing
: eleteObject(hmem);
before (after?) you do the unlock.
This helps with other resources such as HANDLE's -- maybe it will help here.
Yours,
Wes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|