Hi all , I have been working on porting VCL toDirectFB. The VCL ported on GDK-DirectFB uses Pango to do the Layout. I needed some pointers analyzing the leaks .The leaks end in the Pango library .
I am freeing all Pango related structures in the GetFontMetric function after the call to pango_context_get_metrics . I fail to understand that how the ported code is causing leaks in low level fontconfig library. Is there a way to find what in my code is causing this leak? Any Pointers / quick suggestions . These are the valgrind traces. I see almost the same trace when i open a document with writer /impress. =3318== Memcheck, a memory error detector. --3318-- Command line --3318-- /opt/openoffice.org2.3/program/soffice.bin --3318-- -view --3318-- ~/simple.ppt --3318-- Startup, with flags: --3318-- -v --3318-- --tool=memcheck --3318-- --leak-check=full --3318-- --show-reachable=no =*=3318== 324,124 (104,448 direct, 219,676 indirect) bytes in 408 blocks are definitely lost in loss record 151 of 154* ==3318== at 0x400593E: realloc (vg_replace_malloc.c:429) ==3318== by 0xAB9E13: (within /usr/lib/libfontconfig.so.1.1.0) ==3318== by 0xABA7E3: (within /usr/lib/libfontconfig.so.1.1.0) ==3318== by 0xABACDB: (within /usr/lib/libfontconfig.so.1.1.0) ==3318== by 0xAB7520: FcFontRenderPrepare (in /usr/lib/libfontconfig.so.1.1.0) ==3318== by 0x6E78B72: pango_fc_font_map_load_fontset (pangofc-fontmap.c:1109) ==3318== by 0x6D72F95: pango_font_map_load_fontset (pango-fontmap.c:107) ==3318== by 0x6D71A41: *pango_context_get_metrics* (pango-context.c:1619) ==3318== by 0x690CF20: *GtkSalGraphics::GetFontMetric**(*ImplFontMetricData*) (in /opt/openoffice.org2.3/program/libvclplug_gtk680li.so.1.1) ==3318== by 0x4124E36: OutputDevice::ImplNewFont() const (in /opt/openoffice.org2.3/program/libvcl680li.so.1.1) ==3318== by 0x41255BF: OutputDevice::GetTextHeight() const (in /opt/openoffice.org2.3/program/libvcl680li.so.1.1) ==3318== by 0x10008587: SvxFont::QuickGetTextSize(OutputDevice const*, String const&, unsigned short, unsigned short, long*) const (in /opt/openoffice.org2.3/program/libsvx680li.so.1.1) The GetFontMetric code snippet :- void GtkSalGraphics::GetFontMetric( ImplFontMetricData *pMetric ) { PangoContext* pcc = gdk_pango_context_get_for_screen (gdk_screen_get_default ()); PangoLanguage* pl = pango_language_get_default( ); PangoFontDescription* pfd = pango_font_description_new(); PangoFontMetrics* pfm; pango_font_description_set_family( pfd, ByteString( mpUseFont->mpFontData->GetFamilyName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() ); pango_font_description_set_size( pfd, mpUseFont->mnHeight * PANGO_SCALE ); * pfm = pango_context_get_metrics( pcc, pfd, pl );* pMetric->mnWidth = pango_font_metrics_get_approximate_char_width( pfm ) / PANGO_SCALE + 5; pMetric->mnAscent = pango_font_metrics_get_ascent( pfm ) / PANGO_SCALE ; pMetric->mnDescent = pango_font_metrics_get_descent( pfm ) / PANGO_SCALE ; pMetric->mnWUnderlineOffset = pango_font_metrics_get_underline_position( pfm ) / PANGO_SCALE; pMetric->mnStrikeoutOffset = pango_font_metrics_get_strikethrough_position( pfm ) / PANGO_SCALE; pMetric->mnIntLeading = 0; pMetric->mnExtLeading = 0; pMetric->mbScalableFont = true; pango_font_description_free(pfd); *pango_font_metrics_unref( pfm ); /*/ *Freed the context metrics * g_object_unref( pcc ); } Regards, Monali.