-
-
Notifications
You must be signed in to change notification settings - Fork 681
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 leaks in handling updates loop #1485
Comments
Roberto Bussolari Il giorno 18 feb 2024, alle ore 13:25, Uladzimir Tsykun ***@***.***> ha scritto:
I noticed large memory leaks when processing a large number of messages. After investigation I found out that these are related to Peer, Username, FileReference database.
So I created a special a Least Recently Used (LRU) MemoryArray DbArray adapter with limited size. This partially solved the problem, memory usage reduced from +500 MB to 60 MB after restart, but there are still memory leaks
2024-02-17 06:41:10.849338 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 62.64 MB, PHP Real 44 MB, now 40.14 MB, peak 50 MB
2024-02-17 06:56:36.449571 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 67.48 MB, PHP Real 48 MB, now 35.96 MB, peak 52 MB
2024-02-17 07:12:02.050498 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 66.29 MB, PHP Real 46 MB, now 37.74 MB, peak 52 MB
2024-02-17 07:27:27.651332 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 66.34 MB, PHP Real 46 MB, now 40.2 MB, peak 54 MB
2024-02-17 07:42:53.252431 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 68.43 MB, PHP Real 48 MB, now 42.51 MB, peak 56 MB
2024-02-17 07:58:18.852877 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 70.45 MB, PHP Real 50 MB, now 44.72 MB, peak 56 MB
2024-02-17 08:13:44.454213 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 72.06 MB, PHP Real 52.5 MB, now 47.78 MB, peak 60.5 MB
2024-02-17 08:29:10.055421 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 74.29 MB, PHP Real 54.5 MB, now 50.68 MB, peak 62.5 MB
2024-02-17 08:44:35.656697 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 76.52 MB, PHP Real 56.5 MB, now 53.29 MB, peak 64.5 MB
2024-02-17 09:00:01.256927 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 78.92 MB, PHP Real 58.5 MB, now 50.1 MB, peak 66.5 MB
2024-02-17 09:15:26.856792 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 81.16 MB, PHP Real 60.5 MB, now 53.36 MB, peak 66.5 MB
2024-02-17 09:30:52.456841 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 83.9 MB, PHP Real 65 MB, now 58.55 MB, peak 73 MB
2024-02-17 09:46:18.057578 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 86.16 MB, PHP Real 67 MB, now 61.33 MB, peak 75 MB
2024-02-17 10:01:43.658044 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 88.35 MB, PHP Real 69 MB, now 63.51 MB, peak 77 MB
2024-02-17 10:17:09.258085 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 90.57 MB, PHP Real 71 MB, now 65.88 MB, peak 79 MB
2024-02-17 10:32:34.858481 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 92.77 MB, PHP Real 73 MB, now 68.2 MB, peak 81 MB
2024-02-17 10:48:00.459272 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 95 MB, PHP Real 75 MB, now 70.74 MB, peak 83 MB
2024-02-17 11:03:26.060398 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 97.05 MB, PHP Real 77 MB, now 67.43 MB, peak 83 MB
2024-02-17 11:18:51.661908 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 97.74 MB, PHP Real 79 MB, now 70.55 MB, peak 85 MB
2024-02-17 11:34:17.262058 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 101.57 MB, PHP Real 81 MB, now 73.18 MB, peak 87 MB
2024-02-17 11:49:42.863397 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 104.82 MB, PHP Real 88 MB, now 80.95 MB, peak 96 MB
2024-02-17 12:05:08.463539 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 107.03 MB, PHP Real 90 MB, now 83.23 MB, peak 96 MB
2024-02-17 12:20:34.063989 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 109.24 MB, PHP Real 92 MB, now 85.53 MB, peak 98 MB
2024-02-17 12:35:59.664383 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 111.51 MB, PHP Real 94 MB, now 88.59 MB, peak 102 MB
2024-02-17 12:51:25.265648 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 113.62 MB, PHP Real 96 MB, now 84.8 MB, peak 102 MB
2024-02-17 13:06:50.865821 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 113.83 MB, PHP Real 96 MB, now 86.91 MB, peak 102 MB
2024-02-17 13:22:16.466524 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 116.01 MB, PHP Real 98 MB, now 89.1 MB, peak 104 MB
2024-02-17 13:37:42.066671 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 118.12 MB, PHP Real 100 MB, now 91.43 MB, peak 106 MB
2024-02-17 13:53:07.666765 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 118.37 MB, PHP Real 100 MB, now 93.23 MB, peak 108 MB
2024-02-17 14:08:33.267200 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 120.57 MB, PHP Real 102 MB, now 95.54 MB, peak 110 MB
2024-02-17 14:23:58.866784 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 122.72 MB, PHP Real 104 MB, now 97.44 MB, peak 112 MB
2024-02-17 14:39:24.467094 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 124.93 MB, PHP Real 106 MB, now 93.29 MB, peak 112 MB
2024-02-17 14:54:50.066821 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 125.07 MB, PHP Real 106 MB, now 95.34 MB, peak 112 MB
2024-02-17 15:10:15.666966 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 125.36 MB, PHP Real 106 MB, now 97.39 MB, peak 114 MB
2024-02-17 15:25:41.267423 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 127.5 MB, PHP Real 108 MB, now 99.06 MB, peak 114 MB
2024-02-17 15:41:06.868354 docker-entrypoint, xxxxxxxxx: Memory usage check: RSS 129.65 MB, PHP Real 110 MB, now 100.97 MB, peak 118 MB
Then I tried to debug with https://github.com/BitOne/php-meminfo, but seems this library not dump Fibers memory stack dump
\Revolt\EventLoop::onSignal(\SIGUSR1, function () {
echo "\n---------\n\n\n-SIGUSR1-\n\n\n";
$file = is_writable("/data") ? '/data/mem_dump.json' : '/tmp/mem_dump.json';
if (\file_exists($file)) {
@\unlink($file);
}
\meminfo_dump(\fopen($file, 'w'));
});
What places in the code can I check, (for example where local caching is used) to fix memory leaks?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
You're using the event handler, and the latest v8 beta, correct? This behavior can be turned off altogether by specifying a TTL of 0 in the settings, at the expense of performance, which is something I do not recommend doing. |
Hi @danog I found it. Problem in MinDatabase cache final class MinDatabase implements TLCallback
{
/**
* Temporary cache during deserialization.
*/
private array $cache = []; I use my own fork for debug memory https://github.com/vtsykun/php-meminfo where fixed bugs BitOne/php-meminfo#133 BitOne/php-meminfo#135
|
Thank you for investigating and finding the issue, fixed in the latest commit! |
Hi @danog it's works now. Thank you for the fast fix and nice software.
|
I noticed large memory leaks when processing a large number of messages. After investigation I found out that these are related to Peer, Username, FileReference database.
So I created a special a Least Recently Used (LRU) MemoryArray DbArray adapter with limited size. This partially solved the problem, memory usage reduced from +500 MB to 60 MB after restart, but there are still memory leaks
Then I tried to debug with https://github.com/BitOne/php-meminfo, but seems this library not dump Fibers memory stack dump
What places in the code can I check, (for example where local caching is used) to fix memory leaks?
The text was updated successfully, but these errors were encountered: