Merge "Limit the max number of thread pool threads in 32-bit Windows" into emu-master-dev
diff --git a/thread-pool.c b/thread-pool.c
index 6fba913..d8d0cba 100644
--- a/thread-pool.c
+++ b/thread-pool.c
@@ -297,7 +297,13 @@
     qemu_mutex_init(&pool->lock);
     qemu_cond_init(&pool->worker_stopped);
     qemu_sem_init(&pool->sem, 0);
+#if defined(_WIN32) && !defined(_WIN64)
+    /* Limit the number of worker thread on 32-bit Windows: usually we only
+     * have 2 GB of address space, and each thread costs us over 1 MB of it. */
+    pool->max_threads = 24;
+#else
     pool->max_threads = 64;
+#endif
     pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool);
 
     QLIST_INIT(&pool->head);