Can anyone tell me what is the purpose of using this function??

CMFCRibbonPanel::CopyFrom(CMFCRibbonPanel& src)

I use:

m_pPanel =

DYNAMIC_DOWNCAST(CMFCRibbonMainPanel, pPanel->GetRuntimeClass()->CreateObject());

m_pPanel -> CopyFrom (*pPanel);

For the code above, it has cause memory leak after i close the application even though I have delete m_pPanel. May I know how to solve it?