Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Different cache folder

Post Reply
alpires2000
Posts: 48
Joined: Sat Dec 09, 2017 4:40 pm

Different cache folder

Post by alpires2000 »

Hi Salvador,

I need to configure a different cache folder for each instance of the form so I put these lines in the OnCreate event.

Code: Select all

GlobalWebView2Loader := TWVLoader.create(self);
GlobalWebView2Loader.UserDataFolder := ExtractFileDir(Application.ExeName) +
  '\Cache'+inttostr(lista_id);
GlobalWebView2Loader.StartWebView2;
Where list_id is a parameter received by the form

Apparently it worked but when I instantiate two or more forms and then close the forms and then the program, a memory leak occurs as shown in the attached image.

In CEF4 I use:

Code: Select all

TempContext := TCefRequestContextRef.New(ExtractFilePath(application.ExeName) + 'cache\cache' + inttostr(lista_id),'', '', false, false, false)
Any idea how can I do this in WebView4?
You do not have the required permissions to view the files attached to this post.
alpires2000
Posts: 48
Joined: Sat Dec 09, 2017 4:40 pm

Re: Different cache folder

Post by alpires2000 »

Hi Salvador, I found this way:

Code: Select all

    WVBrowser1.ProfileName := 'cache' + inttostr(lista_id);
    WVBrowser1.CreateBrowser(WVWindowParent1.Handle);
is this correct?
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Different cache folder

Post by salvadordf »

alpires2000 wrote: Thu May 04, 2023 2:31 am Hi Salvador, I found this way:

Code: Select all

    WVBrowser1.ProfileName := 'cache' + inttostr(lista_id);
    WVBrowser1.CreateBrowser(WVWindowParent1.Handle);
is this correct?
Yes, that's correct. Using a different profile name will create a different profile directory path on disk.
https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controlleroptions?view=webview2-1.0.1722.45#get_profilename
Post Reply