Bug 486861 - Memory leak in EWS resource
Summary: Memory leak in EWS resource
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: EWS Resource (show other bugs)
Version: 6.0.2
Platform: Neon Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-10 17:25 UTC by Louis Moureaux
Modified: 2024-06-26 13:14 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Louis Moureaux 2024-05-10 17:25:25 UTC
SUMMARY

The memory usage of the EWS resource keeps growing until I kill the process.

STEPS TO REPRODUCE
1. Configure an EWS resources
2. Sync it
3. Wait a few hours

OBSERVED RESULT

The akonadi_ews_resource process uses all available RAM and renders the system unusable.
On my system, the resource leaks about 1MB/s so I need to restart it after ~1h.

EXPECTED RESULT

Memory usage is roughly constant.

SOFTWARE/OS VERSIONS

Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.5.0-28-generic (64-bit)
Graphics Platform: Wayland
Memory: 15.3 Gio of RAM

ADDITIONAL INFORMATION

My mailbox contains thousands of emails totaling about 1GB. The akonadi log gets filled quickly with the following message:
org.kde.pim.ews.client: Failed to process EWS request:

I'm willing to investigate more (and find the leak) if someone would tell me how to start an agent manually.
Comment 1 Bug Janitor Service 2024-06-25 21:26:50 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/168
Comment 2 Luca Beltrame 2024-06-26 05:54:51 UTC
For sure related to https://bugs.kde.org/show_bug.cgi?id=485799 (either this one or the other should be marked as duplicate)
Comment 3 Luca Beltrame 2024-06-26 06:06:37 UTC
Git commit aacd0807f13d0694b2bde515964b5f081973da5f by Luca Beltrame, on behalf of Louis Moureaux.
Committed on 26/06/2024 at 06:06.
Pushed by lbeltrame into branch 'master'.

Fix a memory leak in TransferJob

TransferJob wasn't releasing its QNetworkReply upon deletion, which
resulted in it and associated resources being leaked. With the many
requests spotted in bug 485799 this leads to heavy resource usage.

| Heaptrack Before | Heaptrack After |
| ------ | ------ |
| ![image](/uploads/3d0957e59804bd9e1a01b62f4717e023/image.png) | ![image](/uploads/45ba2527c0a4a1f34da889e01ca763b9/image.png) |

M  +6    -5    resources/ews/ewsclient/transferjob.cpp
M  +3    -1    resources/ews/ewsclient/transferjob.h

https://invent.kde.org/pim/kdepim-runtime/-/commit/aacd0807f13d0694b2bde515964b5f081973da5f
Comment 4 Carl Schwan 2024-06-26 08:27:45 UTC
Git commit 6173a24fb1aa4a13978185184b74c96934c2aa50 by Carl Schwan.
Committed on 26/06/2024 at 08:27.
Pushed by carlschwan into branch 'release/24.05'.

Fix a memory leak in TransferJob

TransferJob wasn't releasing its QNetworkReply upon deletion, which
resulted in it and associated resources being leaked. With the many
requests spotted in bug 485799 this leads to heavy resource usage.

| Heaptrack Before | Heaptrack After |
| ------ | ------ |
| ![image](/uploads/3d0957e59804bd9e1a01b62f4717e023/image.png) | ![image](/uploads/45ba2527c0a4a1f34da889e01ca763b9/image.png) |


(cherry picked from commit aacd0807f13d0694b2bde515964b5f081973da5f)

b6fe76cf Fix a memory leak in TransferJob

Co-authored-by: Louis Moureaux <m_louis30@yahoo.com>

M  +6    -5    resources/ews/ewsclient/transferjob.cpp
M  +3    -1    resources/ews/ewsclient/transferjob.h

https://invent.kde.org/pim/kdepim-runtime/-/commit/6173a24fb1aa4a13978185184b74c96934c2aa50
Comment 5 Louis Moureaux 2024-06-26 13:14:53 UTC
> For sure related to https://bugs.kde.org/show_bug.cgi?id=485799 (either this one or the other should be marked as duplicate)

No, these are two different issues. The resource shouldn't spam hundreds of requests as described in 485799, especially if they all fail.