[cairo] ODP: Memory leak when using cairo_show_text

Rafał Jopek rafaljopek at hotmail.com
Thu Dec 8 11:16:34 UTC 2022


I added this line but it doesn't change anything `cairo_show_text( w->cr, par1 ? malloc_strdup( par1 ) : NULL );`
Below is the source code.

https://github.com/dev-harbour/bluesea/blob/main/src/bluesea.c#L457


Tests also performed on this source code does not change anything:

```
      cairo_scaled_font_t *scaled_face = cairo_get_scaled_font( w->cr );
      cairo_glyph_t *glyphs = malloc( ( strlen( par1 ) ) * sizeof( cairo_glyph_t ) );
      int glyph_count;
      cairo_text_cluster_t *clusters = NULL;
      int cluster_count;
      cairo_text_cluster_flags_t clusterflags;
      cairo_font_extents_t extents;

      hex_to_rgb( w->cr, par4 );
      cairo_scaled_font_extents ( scaled_face, &extents );
      cairo_scaled_font_text_to_glyphs( scaled_face, par2, par3, par1, strlen( par1 ), &glyphs, &glyph_count, &clusters, &cluster_count, &clusterflags );
      cairo_show_text_glyphs ( w->cr, par1, strlen( par1 ), glyphs, glyph_count, clusters, cluster_count, clusterflags );
      free( glyphs );
      cairo_text_cluster_free( clusters );

```

--Rafał


________________________________
Od: Luca Bacci <luca.bacci982 at gmail.com>
Wysłane: czwartek, 8 grudnia 2022 12:07
Do: Rafał Jopek <rafaljopek at hotmail.com>
DW: cairo at cairographics.org <cairo at cairographics.org>
Temat: Re: [cairo] Memory leak when using cairo_show_text

Consider that Cairo internally keeps a glyph cache, so the memory increase you experience may just be due to internal caching. Can you share the code and some data? I can make some test

Luca

Il gio 8 dic 2022, 12:01 Rafał Jopek <rafaljopek at hotmail.com<mailto:rafaljopek at hotmail.com>> ha scritto:
MSYS2 was used in the tests
Version Cairo 1.17.6-3


--Rafał

________________________________
Od: Luca Bacci <luca.bacci982 at gmail.com<mailto:luca.bacci982 at gmail.com>>
Wysłane: czwartek, 8 grudnia 2022 11:29
Do: Rafał Jopek <rafaljopek at hotmail.com<mailto:rafaljopek at hotmail.com>>
DW: cairo at cairographics.org<mailto:cairo at cairographics.org> <cairo at cairographics.org<mailto:cairo at cairographics.org>>
Temat: Re: [cairo] Memory leak when using cairo_show_text

Hello Rafał,

Which OS are you using and which Cairo version?

Luca

Il gio 8 dic 2022, 11:02 Rafał Jopek <rafaljopek at hotmail.com<mailto:rafaljopek at hotmail.com>> ha scritto:
Hi,

Tests done on function `cairo_show_text` and also other functions that draw text cause
increasing the physical memory used by the active process.

For example if I use function to draw shapes `cairo_rectangle` or other
Everything is fine, the memory behaves perfectly.

Kind regards,
--Rafał

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20221208/cdacf28d/attachment.htm>


More information about the cairo mailing list