mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Vega] Fix charts are leaking memory on each refresh (#147309)
Closes: #146170 **Summary:** [Vega] Fix charts are leaking memory on each refresh **Steps for checking:** 1. Create a new `Dashboard` with one `Vega Visualization `(or two) 2. Open **Dev tools** -> **Memory** -> **Heap snapshot** -> **Take snapshot** (execute `Collect Garbage` before) 3. Do refresh `Dashboard` 4. Execute step 2 and compare snapshots **Before:** <img width="767" alt="image" src="https://user-images.githubusercontent.com/20072247/206700742-4f6cb8ad-5a0f-41a5-8a0a-6f058f43d124.png"> **After:** <img width="765" alt="image" src="https://user-images.githubusercontent.com/20072247/206700824-9f96e44a-7860-47fa-ba3e-acf9b05b1ae1.png"> Co-authored-by: Yaroslav Kuznietsov <kuznetsov.yaroslav.yk@gmail.com>
This commit is contained in:
parent
24e2fcf470
commit
df65cd907c
2 changed files with 5 additions and 1 deletions
|
@ -80,7 +80,7 @@ const serializeColumns = (item: Record<string, unknown>, columns: string[]) => {
|
|||
};
|
||||
|
||||
export class VegaAdapter {
|
||||
private debugValuesSubject = new ReplaySubject<DebugValues>();
|
||||
private debugValuesSubject = new ReplaySubject<DebugValues>(1);
|
||||
private error = new BehaviorSubject<string | undefined>(undefined);
|
||||
|
||||
bindInspectValues(debugValues: DebugValues) {
|
||||
|
|
|
@ -142,6 +142,7 @@ export class VegaBaseView {
|
|||
this._view.finalize();
|
||||
}
|
||||
this._view = null;
|
||||
this._vegaViewConfig = null;
|
||||
});
|
||||
|
||||
this._vegaViewConfig = this.createViewConfig();
|
||||
|
@ -502,6 +503,9 @@ export class VegaBaseView {
|
|||
// On dispose, clean up, but don't use undefined to prevent repeated debug statements
|
||||
this._addDestroyHandler(() => {
|
||||
if (debugObj === window.VEGA_DEBUG) {
|
||||
window.VEGA_DEBUG.view = null;
|
||||
window.VEGA_DEBUG.vega_spec = null;
|
||||
window.VEGA_DEBUG.vegalite_spec = null;
|
||||
window.VEGA_DEBUG = null;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue