Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/changes/@visactor/vtable/fix-mem_leak_2026-03-02-13-18.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix(core): prevent memory leaks in table cleanup",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
42 changes: 21 additions & 21 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions packages/vtable/examples/debug/mem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable */
import * as VTable from '../../src';
import VChart from '@visactor/vchart';
import { bindDebugTool } from '../../src/scenegraph/debug-tool';

const CONTAINER_ID = 'vTable';
VTable.register.chartModule('vchart', VChart);
export function createTable() {
const option = {
columns: [
{ field: 'id', title: 'ID', width: 80 },
{ field: 'name', title: '姓名', width: 120 },
{ field: 'age', title: '年龄', width: 80 },
{ field: 'city', title: '城市', width: 120 }
],
records: Array.from({ length: 10000 }, (_, i) => ({
id: i,
name: `张三${i}`,
age: i,
city: `城市${i}`
}))
};
// document.getElementById(CONTAINER_ID).parentElement.style.display = 'none';
let tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
// window.tableInstance = instance;

// tableInstance.onVChartEvent('mouseover', args => {
// console.log('listenChart mouseover', args);
// });

// bindDebugTool(tableInstance.scenegraph.stage, {
// customGrapicKeys: ['col', 'row']
// });

const update = async () => {
// 执行20次release / new
for (let i = 0; i < 20; i++) {
await new Promise(resolve => setTimeout(resolve, 200));
// // tableInstance.release();
// // instance.scenegraph.component.vScrollBar.release();
// // instance.scenegraph.component.hScrollBar.release();
// // instance.scenegraph.stage.removeAllChild();
// // delete instance.scenegraph.stage.table;
// // instance.scenegraph.clearCells();
// tableInstance.scenegraph.component.vScrollBar.release();
// tableInstance.scenegraph.component.hScrollBar.release();
// tableInstance.animationManager.clear();
// tableInstance.animationManager.ticker.release();
// // instance.animationManager.ticker = null;
// // instance.animationManager = null;
// tableInstance.scenegraph.stage.ticker.release();
tableInstance.release();
tableInstance = null;
await new Promise(resolve => setTimeout(resolve, 200));
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
console.log(`第${i}次new完成`);
}
};

window.update = update;
// update();
}
4 changes: 4 additions & 0 deletions packages/vtable/examples/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const menus = [
{
path: 'debug',
name: 'scroll'
},
{
path: 'debug',
name: 'mem'
}
]
},
Expand Down
10 changes: 5 additions & 5 deletions packages/vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
},
"dependencies": {
"@visactor/vtable-editors": "workspace:*",
"@visactor/vrender-core": "~1.0.40",
"@visactor/vrender-kits": "~1.0.40",
"@visactor/vrender-components": "~1.0.40",
"@visactor/vrender-animate": "~1.0.40",
"@visactor/vrender-core": "~1.0.41",
"@visactor/vrender-kits": "~1.0.41",
"@visactor/vrender-components": "~1.0.41",
"@visactor/vrender-animate": "~1.0.41",
"@visactor/vutils": "~1.0.17",
"@visactor/vscale": "~1.0.17",
"@visactor/vdataset": "~1.0.17",
Expand Down Expand Up @@ -133,4 +133,4 @@
"url": "https://github.com/VisActor/VTable.git",
"directory": "packages/vtable"
}
}
}
7 changes: 7 additions & 0 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,13 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
* @returns {void}
*/
release(): void {
// for memory leak of VRender Event
this.scenegraph?.component?.vScrollBar?.release();
this.scenegraph?.component?.hScrollBar?.release();
this.animationManager.clear();
this.animationManager.ticker.release();
this.scenegraph?.stage?.ticker?.release();

const internalProps = this.internalProps;
if (this.isReleased) {
return;
Expand Down
Loading