Discussion:
[directfb-users] Memleak on IDirectFBSurface->Clear on X11
Holger Freyther
2011-10-18 19:56:14 UTC
Permalink
Hi,

I am testing the Qt5 DirectFB skeleton and I see the following memleak
(DiretFB does not complan about leaked surfaces). I wonder if this looks
like something in DirectFB? The surface itself does not appear to be
leaked.


==24294== 62,012,080 bytes in 60 blocks are definitely lost in loss record 324
of 326
==24294== at 0x4028876: malloc (vg_replace_malloc.c:236)
==24294== by 0x70643DD: direct_malloc (mem.c:152)
==24294== by 0x6EB7656: localAllocateBuffer (local_surface_pool.c:147)
==24294== by 0x6ECD054: dfb_surface_pool_allocate (surface_pool.c:614)
==24294== by 0x6ECF531: dfb_surface_pools_allocate (surface_pool.c:507)
==24294== by 0x6E8005F: ISurface_Real__PreLockBuffer (CoreSurface_real.c:251)
==24294== by 0x6E7EDCB: CoreSurface_PreLockBuffer (CoreSurface.c:139)
==24294== by 0x6EC7162: dfb_surface_buffer_lock (surface_buffer.c:315)
==24294== by 0x6EC2AC2: dfb_surface_lock_buffer (surface.c:644)
==24294== by 0x6F3DE4F: gAcquire (generic.c:8417)
==24294== by 0x6E98A1F: dfb_gfxcard_fillrectangles (gfxcard.c:1006)
==24294== by 0x6E748C7: CoreGraphicsStateClient_FillRectangles
(CoreGraphicsStateClient.c:323)
==24294== by 0x6EED7BC: IDirectFBSurface_Clear (idirectfbsurface.c:735)
==24294== by 0x6E28993: QDirectFbBlitter::QDirectFbBlitter(QSize const&,
bool) (qdirectfbblitter.cpp:93)
==24294== by 0x6E271B6: QDirectFbBlitterPlatformPixmap::createBlittable(QSize
const&, bool) const (qdirectfbblitter.h:93)
==24294== by 0x492AD91: QBlittablePlatformPixmap::blittable() const
(qpixmap_blitter.cpp:81)
==24294== by 0x492B314: QBlittablePlatformPixmap::hasAlphaChannel() const
(qpixmap_blitter.cpp:186)
==24294== by 0x492B0F3: QBlittablePlatformPixmap::fill(QColor const&)
(qpixmap_blitter.cpp:141)
==24294== by 0x4920249: QPixmap::fill(QColor const&) (qpixmap.cpp:885)
==24294== by 0x804883E: main (main.cpp:15)
Holger Freyther
2011-10-23 12:32:24 UTC
Permalink
Holger Freyther <***@...> writes:

Hi,

here is a minimal example. How should I properly release
the surface and anything that is attached to it?

1.) valgrind shows use after free in the windowstack
2.) IDirectFBSurface->Clear() creates a memory leak, this is with
directfb-1.4 as of today.


#include <directfb.h>

int main(int argc, char **argv)
{
DFBResult ret;
IDirectFB *dfb;
IDirectFBSurface *surface;

/* Initialize DirectFB. */
ret = DirectFBInit( &argc, &argv );
if (ret) {
D_DERROR( ret, "DFBTest/Resize: DirectFBInit() failed!\n" );
return ret;
}

/* Create super interface. */
ret = DirectFBCreate( &dfb );
if (ret) {
D_DERROR( ret, "DFBTest/Resize: DirectFBCreate() failed!\n" );
return ret;
}

DFBSurfaceDescription surfaceDesc;
memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription));
surfaceDesc.width = 100;
surfaceDesc.height = 200;

surfaceDesc.caps = DSCAPS_PREMULTIPLIED;
surfaceDesc.pixelformat = DSPF_ARGB;
surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT);


for (int i = 0; i < 10; ++i) {
dfb->CreateSurface(dfb , &surfaceDesc, &surface);
surface->Clear(surface, 0, 0, 0, 0);
surface->Release(surface);
}

dfb->Release(dfb);
return 0;
}
Holger Freyther
2011-10-23 13:46:35 UTC
Permalink
Holger Freyther <***@...> writes:
Denis Oliver Kropp
2011-10-30 13:26:21 UTC
Permalink
Oh, sorry, I should have read that before committing the fix, thanks anyhow!

The code broke when the surface pool was adjusted for singe app only execution.
Loading...