3

How to destroy the Tchromium component dynamically created ? I'm using in a DLL , the component necessary to create and destroy it several times without deallocate the DLL, the problem is that is not releasing memory and is unable to clear the cache folder. If I use CefShutDown problems occur in time to recreate the browser again. I'm using the latest version of DCEF3 . Create dynamically like this:

crm := TChromium.Create(Form1);
crm.SetParentComponent (Panel2);
crm.Align := alClient;

to destroy tried in several ways:

FreeAndNil(crm);
crm.free;
crm := nil;
CefShutDown;

The CefShutDown resolved in time to destroy , the problem is occurring by the time I try again recreate the component without deallocate my DLL.

Also solve another problem I'm having with the UserAgent can not change the recreation of the browser.

I appreciate any suggestions to solve my problem.

LU RD
  • 34,438
  • 5
  • 88
  • 296
  • [Related to CEF1](http://stackoverflow.com/q/16080509/960757); I'm not sure if they added some cache cleaning support into CEF3 though. – TLama May 14 '15 at 14:29
  • Once created the browser you can change the UserAgent ? Would I like to each navigation change this information . If so , it would be a resolution to my problem in question – Junior Miguel Vieira May 14 '15 at 14:41
  • No, that is set only at initialization. But you can handle the [`OnBeforeResourceLoad`](http://magpcss.org/ceforum/apidocs3/projects/%28default%29/CefRequestHandler.html#OnBeforeResourceLoad) event and modify the user agent header field for each request. – TLama May 14 '15 at 15:11
  • Tlama friend , you have an example of how I use OnBeforeResourceLoad ? – Junior Miguel Vieira May 18 '15 at 12:35

1 Answers1

6

This behaviour is as designed. Issue 1237 on the Chromium issue tracker is identical to your issue. The relevant excerpt is:

CefInitialize/CefShutdown cannot be called multiple times in the same process. You can create/destroy multiple browser windows without re-initializing CEF.

You will have to refrain from calling CefShutDown.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490