locked
Memory leak of webbrowser OCX on WinCE6.0 RRS feed

  • Question

  • Hi ,

    I add the following codes to a timer and set the timer to 15 seconds.the memory are increasing until it is out of memory. So I think there is memory leak of webbrowser on WinCE6.0.Please help confirm:

    CWnd m_wndBrowser;

    IWebBrowser2* m_pWebBrowser;

    CWebBrowserTestCEDlg::OnTimer(UINT_PTR nIDEvent)

    {

    // TODO: Add your message handler code here and/or call default

    if( 1 == nIDEvent )

    {

    CRect client;

    GetClientRect( &client );

    // create control

    if( !m_wndBrowser.CreateControl( CLSID_WebBrowser, NULL,

    WS_VISIBLE | WS_CHILD, client,

    this, AFX_IDW_PANE_FIRST ) )

    {

    m_wndBrowser.DestroyWindow();

    return;

    }

    IUnknown *pUnk = m_wndBrowser.GetControlUnknown();

    HRESULT hr = pUnk->QueryInterface( IID_IWebBrowser, (

    void **)&m_pWebBrowser );

    if( FAILED(hr) )

    {

    m_wndBrowser.DestroyWindow();

    m_pWebBrowser = NULL;

    return;

    }

    m_wndBrowser.SetWindowPos( NULL, 0, 0, client.right, client.bottom,

    SWP_NOACTIVATE | SWP_NOZORDER );

    hr = m_pWebBrowser->GoHome();

    if( m_pWebBrowser != NULL )

    {

    m_pWebBrowser->Release();

    m_pWebBrowser = NULL;

    }

    }

    CDialog::OnTimer(nIDEvent);

    }

    Friday, October 12, 2012 7:54 AM

Answers

  • From msdn, the QueryInterface method returns S_OK if the interface is supported, and E_NOINTERFACE otherwise. If ppvObject is NULL, this method returns E_POINTER.

    Maybe this FAILED(hr) assertion is wrong.


    Please not forget mark your answer, and unmark your disagreed point.

    • Proposed as answer by Elegentin Xie Monday, October 22, 2012 6:20 AM
    • Marked as answer by Elegentin Xie Tuesday, October 30, 2012 7:09 AM
    Wednesday, October 17, 2012 7:50 AM