🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
2 messages
2 total messages Started by Eduardo Jauch Sun, 04 Feb 2007 14:47
TCppWebBrowser use of memory (consuming it all)
#429
Author: Eduardo Jauch
Date: Sun, 04 Feb 2007 14:47
160 lines
5073 bytes
Hi :)
Me again ;)

I was able to create some code looking here, google groups and a link 
that Remy posted here on the Interfaces (MUCH useful! Thanks Remy)...

The program works fine.
But the amount of memory "allocated" by the process always incrase...
Because I'm a newbe to programming with TCppWebBrowser, I can't find 
where this memory is been allocated and not released.

Like you can see (if I'm wrong, please, teel me), I'm not allocating 
memory myself.

Anyway,

To work out this memory usage problem, I create a simpler version of the 
program. I show you the code below.

After click the "iniciar_bt" button, only these three functions are 
executed:

BrowserNavigateComplete2
EncontrarFrame
BrowserDocumentComplete

I'm try to debug, while observing the use of memory (from task maneger) 
I figured that when the program leaves the function 
BrowserDocumentComplete, the memory that was "catch" when enter, is not 
all freed then..

Any ideas of what I'm doing wrong?





//---------------------------------------------------------------------------

void __fastcall TjanelaPrincipal::iniciar_btClick(TObject *Sender)
{
   Browser->Navigate(WideString("www.visto-eua.com.br"));
}

//---------------------------------------------------------------------------
IHTMLDocument2 *TjanelaPrincipal::EncontrarFrame(WideString frame_name)
{
   IHTMLDocument2 *FrameDoc;
   FrameDoc = NULL;

   if( Browser->Document )
   {
     IHTMLDocument2 *Doc = NULL;
     Browser->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc);

     if( Doc )
     {
       IHTMLFramesCollection2 *Frames;
       Doc->get_frames(&Frames);
       Doc->Release();

       if( Frames )
       {
         TVariant IndexOrName = frame_name;
         TVariant Frame;
         Frames->item(&IndexOrName, &Frame);
         Frames->Release();

         if( (V_VT(&Frame) == VT_DISPATCH) && (V_DISPATCH(&Frame) != NULL) )
         {
           IHTMLWindow2 *Window;
 
V_DISPATCH(&Frame)->QueryInterface(IID_IHTMLWindow2,(LPVOID*)&Window);

           if( Window )
             Window->get_document(&FrameDoc);

           Window->Release();
         }
       }
     }
   }

   return FrameDoc;
}
//---------------------------------------------------------------------------

void __fastcall TjanelaPrincipal::BrowserNavigateComplete2(TObject *Sender,
       LPDISPATCH pDisp, Variant *URL)
{
   if (!CurDispatch)
     CurDispatch = pDisp; // save for comparison
}
//---------------------------------------------------------------------------

void __fastcall TjanelaPrincipal::BrowserDocumentComplete(TObject *Sender,
       LPDISPATCH pDisp, Variant *URL)
{
   IHTMLDocument2 *FrameDoc;
   TVariant FrameName("iContent");
   IHTMLElementCollection *All;
   IDispatch *Disp;
   IHTMLInputElement *pInput;

   if (pDisp == CurDispatch)
   {
     CurDispatch = NULL;

     FrameDoc = EncontrarFrame(WideString("iContent"));

     if( FrameDoc )
       FrameDoc->get_all(&All);
     else
       return;

     if(!All)
     {
       FrameDoc->Release();
       return;
     }

     if(pagina == 1)
     {
       pagina = 2;
       FrameDoc->Release();
       All->Release();
 
Browser->Navigate(WideString("http://www.visto-eua.com.br/agendamento-web/login?redirect=/agenciadores.do"), 
NULL, &FrameName);
     }
     else if(pagina == 2)
     {
       All->item(TVariant(WideString("login")), TVariant(0), &Disp);
       if( !Disp ) return;

       Disp->QueryInterface(IID_IHTMLInputElement, (LPVOID*)&pInput);
       Disp->Release();

       if( !pInput ) return;
       pInput->put_value(WideString ("MyLogin"));
       pInput->Release();

       All->item(TVariant(WideString("senha")), TVariant(0), &Disp);
       if( !Disp ) return;

       Disp->QueryInterface(IID_IHTMLInputElement, (LPVOID*)&pInput);
       Disp->Release();

       if( !pInput ) return;

       pInput->put_value(WideString("MyPassword"));
       pInput->Release();

       pagina = 1;
       FrameDoc->Release();
       All->Release();
       Browser->GoBack();
     }
   }
}
Re: TCppWebBrowser use of memory (consuming it all)
#430
Author: Eduardo Jauch
Date: Sun, 04 Feb 2007 16:37
10 lines
1294 bytes
I'm starting to believe that there a problem with the IE...

Rhe same behaviour I have when use the IE. Every page increase the 
amount of memory to the process...

I disabled images and everithing that seens to use memory, but don't work...

Anyone knows why this occour? The IE have some type of bug?

Thanks! :)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads