beyondcode / herd-community

86 stars 1 forks source link

[Bug]: High memory usage and application freeze when using Mails extensively in Pro version #749

Closed mathiaswillburger closed 4 months ago

mathiaswillburger commented 5 months ago

Platform

Windows

Operating system version

Windows 11

System architecture

Windows

Herd Version

1.6.1

PHP Version

PHP 8.3.7

Bug description

The usual memory usage in Windows while developing is around 300-500MB. However, after testing many emails and starting to delete them, the memory usage rises to 3000MB, and the application freezes. Once the mail window is closed, memory usage immediately goes down to the regular levels.

Steps to reproduce

Send 50+ emails to the Herd mail service, navigate to the mail window and delete single items. After a couple of attempts, the application starts to freeze.

Relevant log output

No response

mathiaswillburger commented 5 months ago

Can all mails somehow be deleted at once? The mail part of the application basically became unresponsive :-(

mathiaswillburger commented 5 months ago

Solved it by deleting mails from the sqlite file in the config folder. Still, would be great to have a stable solution for handling bigger amount of mails.

sschlein commented 5 months ago

Sorry that I didn't send you a reply here, I'll look into this later this week!

sschlein commented 5 months ago

@mathiaswillburger I tried this on multiple systems but haven't been able to reproduce this issue. Are these mails with attachments, are they specifically long, contain lots of images (embedded or loading from a server?). Are there any other hints that you can give so that I can get this problem here as well?

I assume it's some kind of memory leak but would need to recreate the situation to have a good fix.

stevegoddard commented 5 months ago

I'm experiencing the same issue. Sending a few thousand emails to Mail. The emails do contain external images (but no attachments). Memory usage goes very high and the emails seems to take a long time to come in (I'm getting the new email notifications long after all the queued jobs have finished). Screenshot attached.

2024-06-04 10_11_04-Task Manager

Maybe this isn't the place for it - but we really need a button to delete all email messages. I can't seem to find any way to clearing all the emails. The documentation says they are stored in an 'internal database' but there is no mention of where this is and how it can be cleared. Frustrating.

sschlein commented 5 months ago

@stevegoddard Thanks for the feedback! I wonder what the expected behaviour would be if you send a few thousand emails locally to any debug service? I can't come up with a way to make that work without extensive memory because it's quite a lot of data 😉

There is an sqlite file at %userprofile%\.config\herd. You can open this file with a database management client like Table Plus and delete all emails. I'll also add a delete all emails button in the settings, so that you can do that after the next update.

stevegoddard commented 5 months ago

Thanks @sschlein - fair comment on the memory. I generally test with small numbers of emails - but decided to do a full run for testing. Live and learn...

That sqlite tip worked perfectly - thank you! I cleared all the mail related tables and then restated the Herd app. If you could add a button to clear all emails that would be really handy.

Thanks again!

sschlein commented 5 months ago

Just added it and it will be fixed in the next version. I've also improved the performance of deleting mailboxes (via right click on the mailbox in the title bar)

mathiaswillburger commented 5 months ago

@sschlein Great to see that improved for the next version. I am looking forward to it.

The emails I tested contained no attachments and just a few social media icons loaded from the server. So it was more about the amount of data rather than the content of each email I guess. And it was not while receiving the data - which I would understand - but once all mails where already stored in the Herd database.

sschlein commented 5 months ago

Yeah there is no lazy loading and all get loaded into the view, so it's a lot of data for the UI state 😅

sschlein commented 4 months ago

Fixed in 1.7+

stevegoddard commented 4 months ago

Fixed in 1.7+

Working brilliantly - thank you!