0

I've a big plain c++ project where I implemented a webbrowser control (the idea come from https://github.com/Tobbe).

Well I inject some external method with the AddCustomObject. The problem is when I need to dispose a big page (1.9KB) with many object (tinymce, jquery ecc) for local editing ... the memory increasing every time I open the page.

I've searched, googled, readed, contacted the original developer... nope.

In the close method the code is this:

      if (ibrowser != 0) {
        IConnectionPointContainer *cpc = 0;
        ibrowser->QueryInterface(IID_IConnectionPointContainer, (void**)&cpc);

        if (cpc != 0) {
            IConnectionPoint *cp = 0;
            cpc->FindConnectionPoint(DIID_DWebBrowserEvents2, &cp);

            if (cp != 0) {
                cp->Unadvise(cookie);
                cp->Release();
            }

            cpc->Release();
        }

        IOleObject *iole = 0;
        ibrowser->QueryInterface(IID_IOleObject, (void**)&iole);

        /*ibrowser->Stop();
        ibrowser->ExecWB(OLECMDID_CLOSE, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
        ibrowser->put_Visible(VARIANT_FALSE);*/
        UINT refCount = ibrowser->Release();
        ibrowser = 0;


        if (iole != 0) {
            iole->Close(OLECLOSE_NOSAVE);
            iole->Release();
        }
    }

Debugging in Vs2008 I've saw many CustomObject::AddRef and Release maybe due to setTimeout

I've no idea how to resolve this... need help!

Thank's!

Andrea

  • Javascript code leaking DOM objects is a chronic problem. Very hard to get the programmer to pay attention to them these days, modern browsers hide the problem by rendering a page in a separate process and discarding the entire process. No such luxury when you use an in-process browser. Other than discarding the browser and creating a new one. – Hans Passant Aug 28 '14 at 14:07
  • Only other thing I see is likely not related to the question or there is other code missing from this snippet. `cp->Unadvise(cookie);` is called but `Advise` hasn't been called so there is no valid cookie to Unadvise for on that object. All the ConnectionPoint processing can be removed if no event sink is being registered. – Michael Petch Sep 06 '14 at 03:23
  • Actually it could be a bug and could leak memory. If somewhere else in the code a ConnectionPoint was registered and advise called and the cookie was filled in, you'd want to call Unadvise on the object that retrieved the cookie. – Michael Petch Sep 06 '14 at 03:57

0 Answers0