[virglrenderer-devel] memory leak on resource_create/destroy
Zhu Yijun
lovemrd at gmail.com
Thu Jul 30 09:16:00 UTC 2020
hi all,
I run monkey test on an android guest which is booted by qemu with
virtual 3D GPU(virgl=on), and find the host used memory increases
continuously. Then use valrand to memcheck qemu process, there are
some blocks of memory leak reported:
==5730== 188,640 bytes in 524 blocks are definitely lost in loss
record 10,169 of 10,189 ==5730== at 0x485959C: calloc
(vg_replace_malloc.c:762)
==5730== by 0x48BEAC7: vrend_renderer_resource_create
(vrend_renderer.c:6649) ==5730== by 0x31E04F:
virgl_cmd_create_resource_3d (virtio-gpu-3d.c:72)
==5730== by 0x31E04F: virtio_gpu_virgl_process_cmd (virtio-gpu-3d.c:419)
==5730== by 0x31BFDB: virtio_gpu_process_cmdq (virtio-gpu.c:888)
==5730== by 0x31CFE3: virtio_gpu_handle_ctrl (virtio-gpu.c:936)
==5730== by 0x31CFE3: virtio_gpu_ctrl_bh (virtio-gpu.c:948)
==5730== by 0x579723: aio_bh_call (async.c:90)
==5730== by 0x579723: aio_bh_poll (async.c:118)
==5730== by 0x57CA03: aio_dispatch (aio-posix.c:461)
==5730== by 0x5795EB: aio_ctx_dispatch (async.c:269)
==5730== by 0x5051E9F: g_main_context_dispatch (in
/usr/lib64/libglib-2.0.so.0.5600.1) ==5730== by 0x57BB93:
glib_pollfds_poll (main-loop.c:215)
==5730== by 0x57BB93: os_host_main_loop_wait (main-loop.c:238)
==5730== by 0x57BB93: main_loop_wait (main-loop.c:497)
==5730== by 0x29956B: main_loop (vl.c:1982)
==5730== by 0x29956B: main (vl.c:4926)
Check the code below, the possible cause is that the reference count
of resource is not zero and then resource will not destroy immediately
once qemu calls VIRTIO_GPU_CMD_RESOURCE_UNREF cmd. It means the res is
still used by surface, sampler_view, so_target and so on objects which
are called "vrend_resource_reference", it looks reasonable.
static void vrend_destroy_resource_object(void *obj_ptr)
{
struct vrend_resource *res = obj_ptr;
if (pipe_reference(&res->base.reference, NULL))
vrend_renderer_resource_destroy(res);
}
However, I find some resources may not be destroyed finally. I add
some printf in qemu and virgl code, when android guest turning off,
qemu receive the right number of VIRTIO_GPU_CMD_RESOURCE_UNREF cmds
from guest created before, but virgl still remain some resources not
destroy finally and cause the vrend_source not free.
So is it the issue of android guest or virglrenderer or else part, it
should not have memory leak anyway, right?
Thanks!
Yijun
More information about the virglrenderer-devel
mailing list