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
+8
View File
@@ -41,6 +41,7 @@ namespace detail {
boost::optional<QPixmap> first() const;
private:
int64_t memoryUsage() const;
void processOffset();
QVector<Frame<QPixmap>> items_;
int index_{0};
@@ -111,6 +112,7 @@ class ImageExpirationPool
{
private:
friend class Image;
friend class CommandController;
ImageExpirationPool();
static ImageExpirationPool &instance();
@@ -126,6 +128,12 @@ private:
*/
void freeOld();
/*
* Debug function that unloads all images in the pool. This is intended to
* test for possible memory leaks from tracked images.
*/
void freeAll();
private:
// Timer to periodically run freeOld()
QTimer *freeTimer_;