Call malloc_trim after loading images

Not sure this is the best place to do it, but at least it is one
place where we tend to do large, temporary allocations.
This commit is contained in:
Matthias Clasen
2024-03-22 21:08:19 -04:00
parent b1eed1c153
commit 0927c3638a
3 changed files with 10 additions and 1 deletions

View File

@@ -30,6 +30,7 @@
#include <jpeglib.h>
#include <jerror.h>
#include <setjmp.h>
#include <malloc.h>
/* {{{ Error handling */
@@ -237,8 +238,10 @@ gdk_load_jpeg (GBytes *input_bytes,
g_bytes_unref (bytes);
malloc_trim (0);
gdk_profiler_end_mark (before, "Load jpeg", NULL);
return texture;
}

View File

@@ -27,6 +27,7 @@
#include "gsk/gl/fp16private.h"
#include <png.h>
#include <stdio.h>
#include <malloc.h>
/* The main difference between the png load/save code here and
* gdk-pixbuf is that we can support loading 16-bit data in the
@@ -300,6 +301,8 @@ gdk_load_png (GBytes *bytes,
g_free (row_pointers);
png_destroy_read_struct (&png, &info, NULL);
malloc_trim (0);
if (GDK_PROFILER_IS_RUNNING)
{
gint64 end = GDK_PROFILER_CURRENT_TIME;

View File

@@ -26,6 +26,7 @@
#include "gdktexturedownloaderprivate.h"
#include <tiffio.h>
#include <malloc.h>
/* Our main interest in tiff as an image format is that it is
* flexible enough to save all our texture formats without
@@ -500,6 +501,8 @@ gdk_load_tiff (GBytes *input_bytes,
TIFFClose (tif);
malloc_trim (0);
if (GDK_PROFILER_IS_RUNNING)
{
gint64 end = GDK_PROFILER_CURRENT_TIME;