memory leak on resource_create/destroy
hi all,
I run monkey test in android guest which booted by qemu with virtual 3D GPU(virgl=on), and find the host used memory increase continuous. 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 cause is that the reference count of resource is not zero and then resource will not destroy immediately once qemu call VIRTIO_GPU_CMD_RESOURCE_UNREF cmd. It means the res is still used by surface, sampler_view, so_target and so on objects which 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, when android guest turning off, I find that qemu will receive VIRTIO_GPU_CMD_RESOURCE_UNREF cmd from guest with all the res id created before, but virgl still remain some resouces 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