Skip to content

[Bug]: g-lite 中 memoize 缓存不释放导致 内存溢出 #3084

@wanglxi1

Description

@wanglxi1

Describe the bug / 问题描述

g-lite 2.3.2 的 css/parser/path.ts:81
const memoizedParsePath = memoize(internalParsePath);
在长期使用过程中,缓存一直不释放

import React, { useRef, useState, useEffect } from 'react';
import { Area, Line } from '@ant-design/plots';

declare type T = {
	t: Date;
	value: number;
	k: string;
}

const HomePage: React.FC = () => {
    const [dataUtil, setDataUtil] = useState<any[]>();  

    useEffect(() => {		
		const delta = 0;
		const count = 3600;
		const legends = 100;
		
		let now = new Date().getTime() / 1000;

		const data:T[] = [];
		const createData = () => {
			let len = count*legends - data.length;
			if(len == 0){
				len = 1;
				data.splice(0, 2);
			}else{
				len = len / legends;
			}
			for (let i = 0; i < len; i++) {
				const d = new Date((now++) * 1000);
				for(let j=0; j<legends; j++){
					data.push({
						t: d,
						value: (now%count) * (j+1),
						k: 'k'+j,
					});
				}
			}
		}

        setInterval(() => {			
			createData();
            setDataUtil([...data]);
        }, delta);
    },[]);    

    

    const config = {
        xField: 't',
		yField: 'value',
		colorField: 'k',
		height: 280,
		data: dataUtil,
		legend: false,
    };

    return (
        <Area {...config} stack />
    );
};

export default HomePage;

Reproduction link / 复现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workingplots统计图表G2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions