Fix memory leaks as reported by DrMemory and Valgrind.

ARM and probably the rest of the arches have significant memory leaks as
they have no release interface.

Additionally, DrMemory does not have 64-bit support and thus I can't
test the 64-bit version under Windows. Under Linux valgrind supports
both 32-bit and 64-bit but there are different macros and code for Linux
and Windows.
This commit is contained in:
farmdve
2016-01-08 01:41:45 +02:00
parent 13726b3d40
commit 036763d6ae
22 changed files with 85 additions and 45 deletions

View File

@@ -28,6 +28,7 @@
#include "config-host.h"
#include "sysemu/sysemu.h"
#include "sysemu/cpus.h"
#include "qemu/thread.h"
#include "exec/address-spaces.h" // debug, can be removed later
@@ -76,7 +77,9 @@ void pause_all_vcpus(struct uc_struct *uc)
CPUState *cpu;
CPU_FOREACH(cpu) {
qemu_thread_join(cpu->thread); // qq: fix qemu_thread_join() to work for instance
qemu_thread_join(uc, cpu->thread); // qq: fix qemu_thread_join() to work for instance
free(cpu->thread);
cpu->thread = NULL;
}
}
@@ -164,6 +167,13 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
CPU_FOREACH(cpu) {
cpu->thread_id = 0;
cpu->created = false;
qemu_cond_destroy(cpu->halt_cond);
free(cpu->halt_cond);
#ifdef _WIN32
if(cpu->hThread)
CloseHandle(cpu->hThread);
#endif
cpu->halt_cond = NULL;
}
qemu_mutex_unlock(&uc->qemu_global_mutex);