Looking at the way disas is structured it seems cap_insn is allocated once (per thread) and re-used for each disassembly so we shouldn't be free'ing it after each usage. In fact the comments to cap_disas_start imply we want to do better than re-initialising the library for every set of instructions we disassemble.
It is true that we don't clean-up any of the disassembly machinery on exit but the same can be said for a lot of QEMU's static state. So currently I don't see a leak rather than a one-time allocation. Unless I can reproduce the leak I'm going to mark this as incomplete for now. ** Changed in: qemu Status: New => Incomplete -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1860610 Title: cap_disas_plugin leaks memory Status in QEMU: Incomplete Bug description: Looking at origin/master head, the function cap_disas_plugin leaks memory. per capstone's examples using their ABI, cs_free(insn, count); needs to called just before cs_close. I discovered this running qemu under valgrind. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1860610/+subscriptions