Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with memory and app lock #1785

Open
celciusjj opened this issue Apr 30, 2024 · 0 comments
Open

Problems with memory and app lock #1785

celciusjj opened this issue Apr 30, 2024 · 0 comments

Comments

@celciusjj
Copy link

celciusjj commented Apr 30, 2024

Initially there was a problem with synchronizing a lot of data over 100MB, and we decided to build a chunk system which would insert data in parts. This was developed and from the application a cycle was built where an applyRemoteChanges is made with the data of each chunk until finishing, but sometimes and on some cell phones the memory fills up, and blocks the application, forcing the application to be closed manually since you can't do anything with it.

Any idea why the application is blocking memory, knowing that writing is done in fragments?

updated:
I did a profiling and the memory seemed to be fine, I used an emulator with very high memory and high heap, and the application still crashes. I think that could be a cpu problem.

Profiling cpu, death point is the red circle
image

The memory increases gradually, the death point is the red circle.
image

The blocking happens on the following line. Which is inside a loop executing sequentially per fragment

        await database.write(() =>
          applyRemoteChanges(changes, {
            db: database,
            sendCreatedAsUpdated: false,
          }),
        );

complete loop

      for await (const url of map) {
        const data = await fetch(url);
        const response = await data.json();
        const { changes, timestamp } = response;

        await database.write(() =>
          applyRemoteChanges(changes, {
            db: database,
            sendCreatedAsUpdated: false,
          }),
        );

        counter--;
        setUrlsSize(counter);
        await setLastPulledAt(database, timestamp);
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant