Skip to content

[Bug]: UI general memory leak (drawers, modals, queries, possibly others) #406

Open
@the-ocean-motion

Description

@the-ocean-motion

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The web browser javascript heap memory size in a Lowcoder app keeps growing indefinitely as previously allocated objects are not released by the Javascript code. This can be observed by opening Window > Task Manager (google chrome) and enabling the JavaScript Memory column (right click on the column labels row to configure which columns are visible).

Expected Behavior

The user keeps interacting with the app, opening and closing drawers/modals for selected table elements. The javascript heap memory size should more or less remain the same throughout time upon a garbage collection and should not increase linearly (or exponentionally).

Steps to reproduce

This can be easily reproduced with the following steps.

  1. Create a new App
  2. Add a new drawer (drawer1) to the App
  3. Add multiple text input fields to the drawer (e.g. 12 text input fieds)
  4. Add new button to the App (not inside the drawer), with the label "Memory Leak Test"
  5. Add a new event to the button that onClick executes the following javascript code:

`function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}

function openDrawer() {
drawer1.openDrawer();
}

function closeDrawer() {
drawer1.closeDrawer();
}

async function memoryLeakLoop() {
for(let i=1;i<=500;i++) {
setTimeout(openDrawer, 10);
setTimeout(closeDrawer, 100);
await delay(200);
}
}

memoryLeakLoop();`

  1. Now preview the app. Make sure to copy paste the app preview url.
  2. Close all Lowcoder tabs and paste the previously copied url to preview the new App
  3. Now after the app loads open the chrome Task Manager.
  4. Wait that the Javascript Memory field decreases and stops changing (or changing very little, meaning all initial app load resources have been released upon garbage collection)
  5. Now press the "Memory Leak Test" button and wait that the drawer stops opening and closing.
  6. Wait until the Javascript Memory decreases and stops changing again.
  7. Now compare the Java heap size with the initial one and notice that the value is much higher (e.g. additional ~25MB that have not been released)

Environment

This was tested on https://app.lowcoder.cloud/ using google chrome, but the same happens in other browsers.

Additional Information

The problem gets worse when for example you have an app that displays a table. Upon clicking of a table row a "queryDetails" is called to retrieve the full information about that table row. A success even handler on queryDetails then opens up a drawer to show the full information of the table row, retrieved with the new query. As the user keeps clicking different rows of the table, Lowcoder doesn't release the memory used by previous executions queryDetails and the pace of increasing of the heap memory size is even worse.

Metadata

Metadata

Labels

BugSomething isn't workingComponentsDedicated to Frontend Visual ComponentsJavascript FrontendPull requests that update Javascript code

Type

No type

Projects

Status

🆕 New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions