mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Optimize memory usage
The two bigger changes here are: 1- The http_client has been moved from the Session to the Browser, allowing its connection pool to be re-used across multiple sessions 2- The browser now has a page_arena which is used for all page-level allocation and which can be re-used between pages (currently retains 1MB of memory). Previously, pages uses an arena that was tied to the lifetime of the page, thus it could not be re-used. Using the Bench allocator for zig-js-runtime, allocated bytes went from 1347037879 to 834932438 (in a RUNS=1000 of puppeteer demo). Various other changes to try to simplify the API and remove the possibility of invalid states. For example, session.newPage() now includes the logic for page.start() so that there should now never be a page that wasn't started.
This commit is contained in:
@@ -96,9 +96,7 @@ pub fn main() !void {
|
||||
var session = try browser.newSession({});
|
||||
|
||||
// page
|
||||
const page = try session.createPage();
|
||||
try page.start(null);
|
||||
defer page.end();
|
||||
const page = try session.createPage(null);
|
||||
|
||||
_ = page.navigate(opts.url, null) catch |err| switch (err) {
|
||||
error.UnsupportedUriScheme, error.UriMissingHost => {
|
||||
|
||||
Reference in New Issue
Block a user