i got following example
class CMyWnd : public CWnd
{
DECLARE_DYNAMIC(CMyWnd)
public:
CMyWnd();
virtual ~CMyWnd();
void Create();
void CreateChildren();
BOOL DestroyChildren();
protected:
DECLARE_MESSAGE_MAP()
private:
CMyActiveX m_oMyActiveX;
};
IMPLEMENT_DYNAMIC(CMyWnd, CWnd)
CMyWnd::CMyWnd()
{
}
CMyWnd::~CMyWnd()
{
DestroyWindow();
}
BEGIN_MESSAGE_MAP(CMyWnd, CWnd)
END_MESSAGE_MAP()
void CMyWnd::Create()
{
CreateEx( 0, AfxRegisterWndClass( WS_OVERLAPPED ), _T(""), WS_OVERLAPPED, 0, 0, 0, 0, NULL, (HMENU) 0 );
}
void CMyWnd::CreateChildren()
{
const int CTRL_ID = 1000;
m_oMyActiveX.Create( NULL, WS_CHILD, CRect( 0, 0, 0, 0 ), this, CTRL_ID, NULL, FALSE, CComBSTR(L"AAAAAAAAAAA") );
}
BOOL CMyWnd::DestroyChildren()
{
m_oMyActiveX.DestroyWindow();
return TRUE;
}
const int TEST_COUNT = 50000;
CMyWnd oMy;
oMy.Create();
for (int i = 0; i < TEST_COUNT; i++) {
oMy.CreateChildren();
oMy.DestroyChildren();
}
const int TEST_COUNT = 50000;
for (int i = 0; i < TEST_COUNT; i++) {
CMyWnd oMy;
oMy.Create();
oMy.CreateChildren();
}
const int TEST_COUNT = 50000;
for (int i = 0; i < TEST_COUNT; i++) {
CMyWnd oMy;
oMy.Create();
oMy.CreateChildren();
oMy.DestroyChildren();
}
I use Performance Monitor tool to monitor private bytes index.
TEST 1: The private bytes is straight line
<img src="http://i60.tinypic.com/28bz0hx.jpg" border="0" alt="Image and video hosting by TinyPic">
TEST 2: The private bytes is gradient line
<img src="http://i62.tinypic.com/2dltabt.jpg" border="0" alt="Image and video hosting by TinyPic">
TEST 3: The private bytes is gradient line
<img src="http://i57.tinypic.com/347cj6w.jpg" border="0" alt="Image and video hosting by TinyPic">
Can you explain why i got difference results ?