[cairo] Memory leak shown by mcheck with very short program - newbie question

Rainer Glaschick rg at g-pb.de
Tue Jan 7 12:41:52 UTC 2020


The following minimal program

#include <cairo.h>
#include <cairo-svg.h>
#include <stdio.h>
#include <mcheck.h>

int main(int argc, char **argv) {
    mtrace();
    cairo_surface_t *surface = cairo_svg_surface_create("xxx.svg", 100.0, 100.0);
    cairo_t *cr = cairo_create(surface);
    cairo_rectangle(cr, 50, 50, 10, 10);
    cairo_pattern_t *pattern = cairo_pattern_create_rgb(1.0, 0, 0);
    cairo_set_source(cr, pattern);
    cairo_fill(cr);
    cairo_pattern_destroy(pattern);
    cairo_destroy(cr);
    cairo_surface_destroy(surface);
}

reports a memory leak, when mcheck is activated:

Memory not freed:
-----------------
   Address     Size     Caller
0x578a64e0    0x4e4  at 0xf749428d
0x578a69c8     0x90  at 0xf74bd150
0x578a6a60     0x34  at 0xf748cac6
0x578a6f98     0x34  at 0xf748cac6

My library versions (Linux  4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux)

||/ Name                     Version           Architektur       Beschreibung
+++-========================-=================-=================-=====================================================
un  libcairo-dev             <keine>           <keine>           (keine Beschreibung vorhanden)
ii  libcairo-gobject2:amd64  1.14.8-1          amd64             Cairo 2D vector graphics library (GObject library)
ii  libcairo-gobject2:i386   1.14.8-1          i386              Cairo 2D vector graphics library (GObject library)
ii  libcairo-perl            1.106-1+b2        i386              Perl interface to the Cairo graphics library
ii  libcairo-script-interpre 1.14.8-1          i386              Cairo 2D vector graphics library (script interpreter)
ii  libcairo2:amd64          1.14.8-1          amd64             Cairo 2D vector graphics library
ii  libcairo2:i386           1.14.8-1          i386              Cairo 2D vector graphics library
ii  libcairo2-dev            1.14.8-1          i386              Development files for the Cairo 2D graphics library
un  libcairo2-doc            <keine>           <keine>           (keine Beschreibung vorhanden)
un  libcairomm-1.0-0         <keine>           <keine>           (keine Beschreibung vorhanden)
rc  libcairomm-1.0-1         1.10.0-1.1        i386              C++ wrappers for Cairo (shared libraries)
ii  libcairomm-1.0-1v5:i386  1.12.0-1+b1       i386              C++ wrappers for Cairo (shared libraries)

Where is my fault? Or is this normal?

Thanks,

Rainer Glaschick, Paderborn, Germany




More information about the cairo mailing list