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

Memory issue #118

Open
daiyam opened this issue Jan 20, 2025 · 6 comments
Open

Memory issue #118

daiyam opened this issue Jan 20, 2025 · 6 comments

Comments

@daiyam
Copy link
Contributor

daiyam commented Jan 20, 2025

Hi @basharovV,

There is a memory usage issue with the CanvasLibraryView component.

With nearly 24K songs, on the album view:

  • at boot, the tauri process takes 2.1GB of memory
  • after a minute, it goes down to 1.2GB
  • with the component disabled, 180MB

With 350 songs, it goes from 400MB to 100MB...

I will try to see where exactly is the problem...

@basharovV
Copy link
Owner

That ain't good, I'll take a look as well.

@daiyam
Copy link
Contributor Author

daiyam commented Jan 25, 2025

Not sure what's going on, I can't replicate the issue with the same code, still in the same session... weird!

I will look if it happens again...

@daiyam
Copy link
Contributor Author

daiyam commented Feb 7, 2025

OK, this is weird! I'm getting the issue again...

@daiyam
Copy link
Contributor Author

daiyam commented Feb 7, 2025

I've tried to fix the issue by updating tauri but it didn't fix it.

The process which eats the memory, is the WebKit's WebContent process launched by tauri.
Now, I'm logging its usage to see what's going on...

@daiyam
Copy link
Contributor Author

daiyam commented Feb 8, 2025

I think I found the issue...

I've added the following code:

navigator.storage.estimate().then(({ usage, quota }) => {
    console.warn(`Database size: ${usage} bytes`);
});

I gave me: Database size: 1_822_589_588 bytes (_ were manually added)
I have 41K songs and 2.6K albums

I've finally found the sqlite file at ~/Library/WebKit/Musicat/WebsiteData/Default.
1.82GB...

So, let's say 30K per song. Its JSON is under 1K.
There is an issue there.

@daiyam
Copy link
Contributor Author

daiyam commented Feb 9, 2025

Ok, the real issue is here:

resultsArray = await results.toArray();

It loads the whole 41K songs in memory (in about 5.8s).

It should load only a part of those songs (maybe 1K) and move the part/window based on the scrolling.
Some filtering and sorting would need to be moved to the database.

The database' size is an issue (1.82GB is way to big for 41K songs) but it isn't the main issue for the memory usage.

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

2 participants