Commit 679aeb36 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Call pthread_detach to make sure the resources get reclaimed

We don't call pthread_join on the threads we create, so apparently
unless we call pthread_detach we just don't get the resources back
(ex stack memory).
parent 1cb51abb
......@@ -351,6 +351,7 @@ intptr_t start_thread(void* (*start_func)(Box*, Box*, Box*), Box* arg1, Box* arg
RELEASE_ASSERT(code == 0, "");
if (VERBOSITY() >= 2)
printf("pthread thread_id: 0x%lx\n", thread_id);
pthread_detach(thread_id);
static_assert(sizeof(pthread_t) <= sizeof(intptr_t), "");
return thread_id;
......
# allow-warning: converting unicode literal to str
# fail-if: '-x' in EXTRA_JIT_ARGS
# Make sure we can spawn a bunch of threads
import threading
cv = threading.Condition()
MAX_WORKERS = 2
nworkers = 0
def worker():
global nworkers
with cv:
nworkers -= 1
cv.notifyAll()
threads = []
for i in xrange(400):
with cv:
while nworkers >= MAX_WORKERS:
cv.wait()
t = threading.Thread(target=worker)
t.start()
threads.append(t)
for t in threads:
t.join()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment