Tool/software: Code Composer Studio
Hi TI,
Following is my sample code to create detached pthread, why it keep occupying heap memory when it finished its task?
Please help. Thanks.
pthread_t create_thread(const int priority, callback cb, void *args)
{
pthread_t pid = NULL;
pthread_attr_t attrs;
struct sched_param schedule;
do {
pthread_attr_init(&attrs);
schedule.sched_priority = priority;
pthread_attr_setschedparam(&attrs, &schedule);
if (pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) != 0) {
error("fail to setdetachstate\n");
break;
}
if (pthread_attr_setstacksize(&attrs, 4096) != 0) {
error("fail to setstacksize\n");
break;
}
if (pthread_create(&pid, &attrs, cb, args) != 0) {
error("fail to create thread\n");
break;
}
} while (false);
pthread_attr_destroy(&attrs);
return pid;
}