tdlight/td/telegram/MemoryManager.h
Andrea Cavalli 45e855f89d Remove most memory related features
I can't maintain anymore this amount of features while keeping the library constantly updated and without bugs. Every merge was taking me multiple hours of revisioning the code. I give up.
From this commit onwards TDLight will only have small useful customizations that are easy to maintain.
Now the people relying on the OptimizeMemory method can restart the session every N hours to free up the memory.
The real way to keep a low memory usage must involve a huge refactoring to allow the unloading of the caches into the sqlite database, similar to what's already happening with messages data. Only Levlam has the ability to implement this without needing to merge the upstream everytime.
2021-09-25 22:11:42 +02:00

65 lines
1.5 KiB
C++

//
// Copyright Andrea Cavalli (nospam@warp.ovh) 2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/actor/actor.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/Timeout.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/files/FileSourceId.h"
#include "td/telegram/FullMessageId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/SecretInputMedia.h"
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/Hints.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include <memory>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
namespace td {
class Td;
struct MemoryStats {
string debug;
MemoryStats() = default;
explicit MemoryStats(string debug) : debug(std::move(debug)) {
}
tl_object_ptr<td_api::memoryStatistics> get_memory_statistics_object() const;
};
class MemoryManager : public Actor {
public:
MemoryManager(Td *td, ActorShared<> parent);
void get_memory_stats(bool full, Promise<MemoryStats> promise) const;
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
void start_up() override;
void tear_down() override;
Td *td_;
ActorShared<> parent_;
};
} // namespace td