Memory cleaning

This commit is contained in:
Andrea Cavalli 2020-04-27 18:32:22 +02:00
parent 4f8b29cfbd
commit 48dcd5d7ff
7 changed files with 39 additions and 0 deletions

View File

@ -13556,4 +13556,10 @@ void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update
}
}
void ContactsManager::memory_cleanup() {
users_full_.clear();
// user_photos_.clear();
chats_full_.clear();
channels_full_.clear();
}
} // namespace td

View File

@ -77,6 +77,8 @@ class ContactsManager : public Actor {
static UserId load_my_id();
void memory_cleanup();
static UserId get_user_id(const tl_object_ptr<telegram_api::User> &user);
static ChatId get_chat_id(const tl_object_ptr<telegram_api::Chat> &chat);
static ChannelId get_channel_id(const tl_object_ptr<telegram_api::Chat> &chat);

View File

@ -6178,4 +6178,20 @@ void StickersManager::get_current_state(vector<td_api::object_ptr<td_api::Update
}
}
void StickersManager::memory_cleanup() {
// stickers_.clear();
// sticker_sets_.clear();
// short_name_to_sticker_set_id_.clear();
// attached_sticker_sets_.clear();
// found_stickers_.clear();
// found_sticker_sets_.clear();
// special_sticker_sets_.clear();
// sticker_set_load_requests_.clear();
// emoji_language_codes_.clear();
// emoji_language_code_versions_.clear();
// emoji_language_code_last_difference_times_.clear();
// emoji_suggestions_urls_.clear();
// dice_messages_.clear();
}
} // namespace td

View File

@ -42,6 +42,8 @@ class StickersManager : public Actor {
public:
static constexpr int64 GREAT_MINDS_SET_ID = 1842540969984001;
void memory_cleanup();
static vector<StickerSetId> convert_sticker_set_ids(const vector<int64> &sticker_set_ids);
static vector<int64> convert_sticker_set_ids(const vector<StickerSetId> &sticker_set_ids);

View File

@ -5022,6 +5022,10 @@ void Td::on_request(uint64 id, td_api::getDatabaseStatistics &request) {
}
void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
contacts_manager_->memory_cleanup();
web_pages_manager_->memory_cleanup();
stickers_manager_->memory_cleanup();
std::vector<FileType> file_types;
for (auto &file_type : request.file_types_) {
if (file_type == nullptr) {

View File

@ -1691,4 +1691,11 @@ vector<FileId> WebPagesManager::get_web_page_file_ids(const WebPage *web_page) c
return result;
}
void WebPagesManager::memory_cleanup() {
// web_pages_.clear();
// web_page_messages_.clear();
// got_web_page_previews_.clear();
// url_to_web_page_id_.clear();
// url_to_file_source_id_.clear();
}
} // namespace td

View File

@ -37,6 +37,8 @@ class WebPagesManager : public Actor {
public:
WebPagesManager(Td *td, ActorShared<> parent);
void memory_cleanup();
WebPagesManager(const WebPagesManager &) = delete;
WebPagesManager &operator=(const WebPagesManager &) = delete;
WebPagesManager(WebPagesManager &&) = delete;