#Memory Leak in the Frontend

1 messages · Page 1 of 1 (latest)

wicked mortar
#

for context, I'm creating a dps meter and just temporarily logging everything

#

not sure what Window might be in this picture

#

are there any obvious problems here with how Window works

#

I suspect it might be the logic in how i'm handling fetching data from the backend:

  onMount(() => {
    fetchData();
    const interval = setInterval(fetchData, 200);

    return () => clearInterval(interval);
  });

  let dpsPlayersWindow: PlayersWindow = $state({ playerRows: [] });

  async function fetchData() {
    try {
      const result = SETTINGS.misc.state.testingMode ? await commands.getTestPlayerWindow() : await commands.getDpsPlayerWindow();
      if (result.status !== "ok") {
        console.warn("timestamp: ", +Date.now(), " Failed to get dps window: ", +Date.now(), result.error);
        return;
      } else {
        dpsPlayersWindow = result.data;
      }
    } catch (e) {
      console.error("Error fetching data: ", e);
    }
  }
#

I'm thinking it might be due to excessive polling and tauri sending another message before the previous one has processed

prime oar
#

also it clears intervals etc automatically

#

also what is dpsPlayerWindow in your code that you directly update?