Adrian Perez de Castro
aperez at igalia.com
Sun Mar 3 04:10:45 PST 2019
On Sun, 03 Mar 2019 09:04:03 +0100, Daniel Berek <berekdaniel at gmail.com> wrote:
> running on a new web process).
> I have two problems to solve, which connecting together.
> 1. At first, I am not sure whats the proper way to load an external
> src="script.js"></script> tag from html file doesnt work, even the html cant
> be loaded. So I have to read the 'script.js' manually, and after each
> webkit_web_view_load_html() I have to execute
available) to all the web pages loaded in the Web view. The recommended way of
achieving that is loading the script once with “webkit_user_script_new()” or
“webkit_user_script_new_for_world()” , then you would add it to a
WebKitUserContentManager  (which you are already using in you example
code), and finally make sure that your web view makes use of your user content
manager (WebKitWebView has a “user-content-manager” property ). Then WebKit
> 2. I have a webview widget (described at the end of this message) and I
> periodically called its destructor (default destructor) to get rid off the
> cached data and made a new instance. Unfortunately, deleting the webview
> widget leaks almost 400kB of memory. So I stopped calling its destructor,
> which is perfectly fine for me (no more leaks, I cant even see the
> external 'script.js' file doesnt work properly, athough
because it *will* make your life easier :)
> Somebody knows whats the proper way for deleting a webview widget
> Or any help is appreciated.
I think destructing the WebKitWebView should correctly deallocate all the
memory used, those 400 KiB of memory lost are suspicious. Are you sure that
there are no other references to the widget (installed signal callbacks, for
example)? Though it might be a problem inside WebKitGTK itself, dunno…
Which kind of “cached data” do you need to get rid of exactly? You may be able
to keep your Web view around, with the user content manager taking care of
clear up caches and other transient data.
Hopefully these tips will help you out a bit :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 195 bytes
Desc: not available
More information about the webkit-gtk