vladimiry / ElectronMail

Unofficial ProtonMail Desktop App
GNU General Public License v3.0
1.5k stars 97 forks source link

Using 1.2-3GB ram on Windows 10 with Local store enabled #372

Closed prestr closed 3 years ago

prestr commented 3 years ago

What can I do or provide to help fix this?

When I have Local store enabled the app use a lot of memory. I've confirmed it has downloaded all the emails (8000 emails - 500mb) and isn't flashing the icon.

As soon as I turn Local store off and restart the app its back down to 100-300mb of Ram.

v4.10.1 Windows 10 - 20H2 (19042.804)

NOTE: I also see it running 7 processes regardless if local store is enabled or not. Not sure if that's relevant.

vladimiry commented 3 years ago

This is by design. The app stores the local store-related data encrypted as a blob (a bunch of bytes) which means the locally stored data is fully encrypted including the metadata (in regular databases for example the columns list or rows count would normally remain unencrypted). This also means that the data will be loaded into the memory in full. I understand that this approach won't please everyone. This way also simplifies the full-text search implementation.

See related note posted in the readme / FAQ:

The app by design flushes and loads to memory the database.bin file as a whole thing but not like encrypting only the specific columns of the database. It's of course not an optimal approach in terms of performance and resource consumption but it allows keeping the metadata hidden. You can see some details here.

As soon as I turn Local store off and restart the app its back down to 100-300mb of Ram.

Exactly since this action empties the data from the database.bin file.

prestr commented 3 years ago

Thanks @vladimiry for the answer. That's fine on my PC with 32GB ram but this now explains why my Mac's with 8GB ram where dieing while running ElectonMail and other apps, there wasn't enough memory. I've switched it off on the Mac's. 👍

vladimiry commented 3 years ago

this now explains why my Mac's with 8GB ram where dieing while running ElectonMail

Try running the app on mac with the --js-flags="--max-old-space-size=4096"-like argument (where 4096 is ~ 4GB). The default max-old-space-size value is about 2048 and so the app will just crash if there is no enough memory. For linux and windows versions I've hardcoded the 6144 value in shortcuts but I have not yet found the simple way to override the defaults for mac system (@electron has the respective issue placed but it remains unresolved).