Thanks alot codeplug, you were absolutely right. Sticking pthread_join in fixed the bulk of the problem instantly. (There is still a 12 byte memory leak hiding somewhere, but its almost too small to worry about)