From 17275fe422719847248cc9dbec79fa614e872d3a Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Apr 2022 20:52:44 +0300 Subject: [PATCH] Output the number of objects to be freed on closing. --- td/telegram/ContactsManager.cpp | 5 +++++ td/telegram/MessagesManager.cpp | 6 ++++++ td/telegram/MessagesManager.h | 1 + td/telegram/UpdatesManager.cpp | 4 ++++ td/telegram/UpdatesManager.h | 2 ++ td/telegram/WebPagesManager.cpp | 2 ++ td/telegram/files/FileManager.cpp | 4 ++++ tdutils/td/utils/Enumerator.h | 5 +++++ 8 files changed, 29 insertions(+) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index b51f43eda..b3bcb27fd 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -3317,6 +3317,11 @@ ContactsManager::~ContactsManager() = default; void ContactsManager::tear_down() { parent_.reset(); + + LOG(DEBUG) << "Have " << users_.size() << " users, " << chats_.size() << " basic groups, " << channels_.size() + << " supergroups and " << secret_chats_.size() << " secret chats to free"; + LOG(DEBUG) << "Have " << users_full_.size() << " full users, " << chats_full_.size() << " full basic groups and " + << channels_full_.size() << " full supergroups to free"; } UserId ContactsManager::load_my_id() { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 3dcbb70f6..325aa560c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -13027,6 +13027,8 @@ class MessagesManager::DialogFiltersLogEvent { void MessagesManager::tear_down() { parent_.reset(); + + LOG(DEBUG) << "Have " << dialogs_.size() << " chats with " << added_message_count_ << " messages to free"; } void MessagesManager::hangup() { @@ -16158,6 +16160,8 @@ void MessagesManager::on_message_deleted(Dialog *d, Message *m, bool is_permanen if (m->notification_id.is_valid()) { delete_notification_id_to_message_id_correspondence(d, m->notification_id, m->message_id); } + + added_message_count_--; } unique_ptr MessagesManager::do_delete_scheduled_message(Dialog *d, MessageId message_id, @@ -34585,6 +34589,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq } } + added_message_count_++; + return result_message; } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index cf7b64699..41fbe33e7 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -3417,6 +3417,7 @@ class MessagesManager final : public Actor { bool running_get_difference_ = false; // true after before_get_difference and false after after_get_difference FlatHashMap, DialogIdHash> dialogs_; + int64 added_message_count_ = 0; FlatHashSet loaded_dialogs_; // dialogs loaded from database, but not added to dialogs_ diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index fea5d34db..8af9fdada 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -177,6 +177,8 @@ UpdatesManager::UpdatesManager(Td *td, ActorShared<> parent) : td_(td), parent_( void UpdatesManager::tear_down() { parent_.reset(); + + LOG(DEBUG) << "Have " << being_processed_updates_ << " unprocessed updates to apply"; } void UpdatesManager::hangup_shared() { @@ -1709,6 +1711,7 @@ void UpdatesManager::on_pending_updates(vector &&result) mutable { send_closure(actor_id, &UpdatesManager::on_pending_updates_processed, std::move(result), std::move(promise)); }); @@ -1831,6 +1834,7 @@ void UpdatesManager::on_pending_updates(vector result, Promise promise) { + being_processed_updates_--; promise.set_result(std::move(result)); } diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 8afa58000..172e73fe6 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -195,6 +195,8 @@ class UpdatesManager final : public Actor { int32 pending_pts_ = 0; int32 pending_qts_ = 0; + int64 being_processed_updates_ = 0; + int32 short_update_date_ = 0; int32 accumulated_pts_count_ = 0; diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index cf5b3ebcb..08438292a 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -413,6 +413,8 @@ WebPagesManager::WebPagesManager(Td *td, ActorShared<> parent) : td_(td), parent void WebPagesManager::tear_down() { parent_.reset(); + + LOG(DEBUG) << "Have " << web_pages_.size() << " web pages to free"; } WebPagesManager::~WebPagesManager() = default; diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index f5cf6e510..da6c236ad 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -3918,6 +3918,10 @@ void FileManager::hangup() { void FileManager::tear_down() { parent_.reset(); + + LOG(DEBUG) << "Have " << file_id_info_.size() << " files with " << file_nodes_.size() << " file nodes, " + << local_location_to_file_id_.size() << " local locations and " << remote_location_info_.size() + << " remote locations to free"; } constexpr int64 FileManager::KEEP_DOWNLOAD_LIMIT; diff --git a/tdutils/td/utils/Enumerator.h b/tdutils/td/utils/Enumerator.h index 998cd8436..e89fd6718 100644 --- a/tdutils/td/utils/Enumerator.h +++ b/tdutils/td/utils/Enumerator.h @@ -37,6 +37,11 @@ class Enumerator { return *arr_[pos]; } + size_t size() const { + CHECK(map_.size() == arr_.size()); + return arr_.size(); + } + private: std::map map_; std::vector arr_;