mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-03 22:13:46 +00:00
Only check for arena leaks AFTER we've triggered all releases
We already did this for the Context, but shutting down the HTTP client can also release resources.
This commit is contained in:
@@ -277,22 +277,24 @@ fn reset(self: *Page, comptime initializing: bool) !void {
|
||||
|
||||
browser.env.destroyContext(self.js);
|
||||
|
||||
// removing a context can trigger finalizers, so we can only check for
|
||||
// a leak after the above.
|
||||
if (comptime IS_DEBUG) {
|
||||
var it = self._arena_pool_leak_track.valueIterator();
|
||||
while (it.next()) |value_ptr| {
|
||||
log.err(.bug, "ArenaPool Leak", .{ .owner = value_ptr.* });
|
||||
}
|
||||
self._arena_pool_leak_track.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
// We force a garbage collection between page navigations to keep v8
|
||||
// memory usage as low as possible.
|
||||
browser.env.memoryPressureNotification(.moderate);
|
||||
self._script_manager.shutdown = true;
|
||||
browser.http_client.abort();
|
||||
self._script_manager.deinit();
|
||||
|
||||
// destroying the context, and aborting the http_client can both cause
|
||||
// resources to be freed. We need to check for a leak after we've finished
|
||||
// all of our cleanup.
|
||||
if (comptime IS_DEBUG) {
|
||||
var it = self._arena_pool_leak_track.valueIterator();
|
||||
while (it.next()) |value_ptr| {
|
||||
log.err(.bug, "ArenaPool Leak", .{ .owner = value_ptr.* });
|
||||
}
|
||||
self._arena_pool_leak_track = .empty;
|
||||
}
|
||||
|
||||
_ = browser.page_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user