hooks icon indicating copy to clipboard operation
hooks copied to clipboard

在轮询中使用useFusionTable 暴漏出来的search.submit() 或者search.reset() 会出现内存溢出。

Open angentle opened this issue 4 years ago • 0 comments

 const timerRef = useRef<any>(null);

  useEffect(() => {
      timerRef.current && clearInterval(timerRef.current);
      timerRef.current = null;
      if (!activeTime) return;
      timerRef.current = setInterval(() => {
        refresh && refresh();
      }, activeTime * 1000);
      return () => {
        timerRef.current && clearInterval(timerRef.current);
        timerRef.current = null;
      };
    }, [activeTime, refresh]);

   // 以下省略一部分代码 仅暴漏search变量
  const {
     // ...
      search,
    } = useFusionTable(getTableData, {
    field: searchFormField,
  });

 const refresh = ()=>{
  search.submit()
 }

下面是每5s轮询一次 内存检测情况:

  1. 使用search.submit: search_submit内存溢出

  2. 手动请求接口更新数据就会正常 手动请求数据_内存情况

希望hook开发人员处理下这个问题。避免内部变量没有被内存回收问题!

angentle avatar Feb 23 '22 07:02 angentle