deallocate all managers
This commit is contained in:
parent
6e05d300dc
commit
4150a89cbb
@ -843,5 +843,9 @@ void AnimationsManager::get_current_state(vector<td_api::object_ptr<td_api::Upda
|
|||||||
updates.push_back(get_update_saved_animations_object());
|
updates.push_back(get_update_saved_animations_object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void AnimationsManager::memory_cleanup() {
|
||||||
|
animations_.clear();
|
||||||
|
animations_.rehash(0);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -31,6 +31,8 @@ class AnimationsManager : public Actor {
|
|||||||
public:
|
public:
|
||||||
AnimationsManager(Td *td, ActorShared<> parent);
|
AnimationsManager(Td *td, ActorShared<> parent);
|
||||||
|
|
||||||
|
void memory_cleanup();
|
||||||
|
|
||||||
int32 get_animation_duration(FileId file_id) const;
|
int32 get_animation_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::animation> get_animation_object(FileId file_id, const char *source);
|
tl_object_ptr<td_api::animation> get_animation_object(FileId file_id, const char *source);
|
||||||
|
@ -274,5 +274,9 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
void AudiosManager::memory_cleanup() {
|
||||||
|
audios_.clear();
|
||||||
|
audios_.rehash(0);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -26,6 +26,8 @@ class AudiosManager {
|
|||||||
public:
|
public:
|
||||||
explicit AudiosManager(Td *td);
|
explicit AudiosManager(Td *td);
|
||||||
|
|
||||||
|
void memory_cleanup();
|
||||||
|
|
||||||
int32 get_audio_duration(FileId file_id) const;
|
int32 get_audio_duration(FileId file_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::audio> get_audio_object(FileId file_id);
|
tl_object_ptr<td_api::audio> get_audio_object(FileId file_id);
|
||||||
|
@ -5129,6 +5129,8 @@ void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
|
|||||||
documents_manager_->memory_cleanup();
|
documents_manager_->memory_cleanup();
|
||||||
video_notes_manager_->memory_cleanup();
|
video_notes_manager_->memory_cleanup();
|
||||||
videos_manager_->memory_cleanup();
|
videos_manager_->memory_cleanup();
|
||||||
|
audios_manager_->memory_cleanup();
|
||||||
|
animations_manager_->memory_cleanup();
|
||||||
file_manager_->memory_cleanup();
|
file_manager_->memory_cleanup();
|
||||||
|
|
||||||
malloc_trim(0);
|
malloc_trim(0);
|
||||||
|
@ -3733,8 +3733,8 @@ void FileManager::destroy_query(int32 file_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileManager::memory_cleanup() {
|
void FileManager::memory_cleanup() {
|
||||||
if (file_id_info_.size() > 1000 || empty_file_ids_.size() < 200) {
|
|
||||||
is_closed_ = true;
|
is_closed_ = true;
|
||||||
auto time = std::time(nullptr);
|
auto time = std::time(nullptr);
|
||||||
|
|
||||||
@ -3742,7 +3742,10 @@ void FileManager::memory_cleanup() {
|
|||||||
auto main_node_id = file_id_info_[i].node_id_;
|
auto main_node_id = file_id_info_[i].node_id_;
|
||||||
if (main_node_id != 0) {
|
if (main_node_id != 0) {
|
||||||
auto &node = file_nodes_[main_node_id];
|
auto &node = file_nodes_[main_node_id];
|
||||||
if (node != nullptr && ((int32) i) == node->main_file_id_.fast_get()) {
|
|
||||||
|
if (node != nullptr &&
|
||||||
|
node->download_priority_ == 0 &&
|
||||||
|
((int32) i) == node->main_file_id_.fast_get()) {
|
||||||
if (time - node->main_file_id_.get_time() > 20 /* MAIN FILE TTL */) {
|
if (time - node->main_file_id_.get_time() > 20 /* MAIN FILE TTL */) {
|
||||||
node->main_file_id_.reset_time();
|
node->main_file_id_.reset_time();
|
||||||
|
|
||||||
@ -3894,7 +3897,6 @@ void FileManager::memory_cleanup() {
|
|||||||
LOG(ERROR) << empty_file_ids_.size() << " empty ids and " << queries_container_.size() << " running queries";
|
LOG(ERROR) << empty_file_ids_.size() << " empty ids and " << queries_container_.size() << " running queries";
|
||||||
is_closed_ = false;
|
is_closed_ = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FileManager::tear_down() {
|
void FileManager::tear_down() {
|
||||||
parent_.reset();
|
parent_.reset();
|
||||||
|
Reference in New Issue
Block a user