Skip to content

Commit

Permalink
Dispose contents of node to contain memory leak (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski authored Mar 27, 2023
1 parent 43b860e commit 31e83c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.0.1](https://github.com/deshaw/jupyterlab-limit-output/compare/v1.0.0...v1.0.1) (2023-03-27)

### Fixed

- Fixed memory leak [#3](https://github.com/deshaw/jupyterlab-limit-output/issues/3)

## [1.0.0](https://github.com/deshaw/jupyterlab-limit-output/compare/v1.0.0...v1.0.0) (2022-02-18)

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jupyterlab-limit-output",
"version": "1.0.0",
"version": "1.0.1",
"description": "Limit output text mime-renders",
"keywords": [
"jupyter",
Expand Down
16 changes: 16 additions & 0 deletions src/renders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ export class MyRenderedText extends RenderedText {
translator: this.translator,
});
}

/**
* Dispose the contents of node to contain potential memory leak.
*
* **Notes**: when user attempts to clean the output using context menu
* they invoke `JupyterFrontEnd.evtContextMenu` which caches the event
* to enable commands and extensions to access it later; this leads to
* a memory leak as the event holds the target node reference.
*/
dispose(): void {
// TODO: remove ts-ignore during JupyterLab 4.0/TypeScript 5.0 migration
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.node.replaceChildren();
super.dispose();
}
}

export const rendererFactory: IRenderMime.IRendererFactory = {
Expand Down

0 comments on commit 31e83c4

Please sign in to comment.