tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

In the official demo has a memory leak #2573

Closed liaoxingquan closed 1 year ago

liaoxingquan commented 1 year ago

td_example.cpp--------------------------------------------------------------------------------------------------- class TdExample { auto create_authentication_query_handler() { return [this, id = authentication_queryid](Object object) { if (id == authentication_queryid) { check_authentication_error(std::move(object)); } }; } ....... } int main() { TdExample example; example.loop(); }

My account has added many groups and a large number of messages have been received, resulting in a gradual increase in memory

levlam commented 1 year ago

TDLib has no memory leaks, which you can check by closing the TDLib instance and using any tool for memory leak detection.

The memory usage can grow over time, because TDLib has a cache which speeds up all requests and gives a big flexibility for the application. The cache contains data about all encountered users and chats and can contain some other data. The size of the in-memory cache can grow over time, so if app wants to flush it, it needs to close and reopen TDLib instance.

liaoxingquan commented 1 year ago

Is there any way to reduce memory by using functions like reset without closing the tdlib instance  @levlam

 

------------------ 原始邮件 ------------------ 发件人: "Aliaksei @.>; 发送时间: 2023年8月14日(星期一) 凌晨4:56 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [tdlib/td] In the official demo has a memory leak (Issue #2573)

TDLib has no memory leaks, which you can check by closing the TDLib instance and using any tool for memory leak detection.

The memory usage can grow over time, because TDLib has a cache which speeds up all requests and gives a big flexibility for the application. The cache contains data about all encountered users and chats and can contain some other data. The size of the in-memory cache can grow over time, so if app wants to flush it, it needs to close and reopen TDLib instance.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

levlam commented 1 year ago

No. The only way is to call close, wait until the instance is closed, and opening another instance.