Add tools to help debug image GC (#4578)

`/debug-force-image-gc` will force garbage collection on all unused images
`/debug-force-image-unload` will force unload all images

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2023-05-27 12:18:08 +00:00
committed by GitHub
parent 5ca7d387e4
commit fb02d59b48
5 changed files with 88 additions and 6 deletions
@@ -16,6 +16,7 @@
#include "controllers/commands/CommandModel.hpp"
#include "controllers/plugins/PluginController.hpp"
#include "controllers/userdata/UserDataController.hpp"
#include "messages/Image.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
@@ -38,6 +39,7 @@
#include "util/FormatTime.hpp"
#include "util/Helpers.hpp"
#include "util/IncognitoBrowser.hpp"
#include "util/PostToThread.hpp"
#include "util/Qt.hpp"
#include "util/StreamerMode.hpp"
#include "util/StreamLink.hpp"
@@ -3211,6 +3213,28 @@ void CommandController::initialize(Settings &, Paths &paths)
return "";
});
this->registerCommand(
"/debug-force-image-gc",
[](const QStringList & /*words*/, auto /*channel*/) -> QString {
runInGuiThread([] {
using namespace chatterino::detail;
auto &iep = ImageExpirationPool::instance();
iep.freeOld();
});
return "";
});
this->registerCommand(
"/debug-force-image-unload",
[](const QStringList & /*words*/, auto /*channel*/) -> QString {
runInGuiThread([] {
using namespace chatterino::detail;
auto &iep = ImageExpirationPool::instance();
iep.freeAll();
});
return "";
});
this->registerCommand("/shield", &commands::shieldModeOn);
this->registerCommand("/shieldoff", &commands::shieldModeOff);