diff --git a/docs/latest/.sha b/docs/latest/.sha index 89db1ba9e..2efb37a6a 100644 --- a/docs/latest/.sha +++ b/docs/latest/.sha @@ -1 +1 @@ -90890e20c01d8b5399983336c5854e43d34ab2e1 \ No newline at end of file +8c3b2e7b9d9949020a6146f04b28dc0cdd1e3e19 \ No newline at end of file diff --git a/docs/latest/api/base-window.md b/docs/latest/api/base-window.md index f7f6d70cc..90f437ba9 100644 --- a/docs/latest/api/base-window.md +++ b/docs/latest/api/base-window.md @@ -71,6 +71,31 @@ const child = new BaseWindow({ parent, modal: true }) * On Linux the type of modal windows will be changed to `dialog`. * On Linux many desktop environments do not support hiding a modal window. +## Resource management + +When you add a [`WebContentsView`](latest/api/web-contents-view.md) to a `BaseWindow` and the `BaseWindow` +is closed, the [`webContents`](latest/api/web-contents.md) of the `WebContentsView` are not destroyed +automatically. + +It is your responsibility to close the `webContents` when you no longer need them, e.g. when +the `BaseWindow` is closed: + +```js +const { BaseWindow, WebContentsView } = require('electron') + +const win = new BaseWindow({ width: 800, height: 600 }) + +const view = new WebContentsView() +win.contentView.addChildView(view) + +win.on('closed', () => { + view.webContents.close() +}) +``` + +Unlike with a [`BrowserWindow`](latest/api/browser-window.md), if you don't explicitly close the +`webContents`, you'll encounter memory leaks. + ## Class: BaseWindow > Create and control windows.