Referring to this construct, posting a full example would be a little too big:
__thread char* buf;
buf = malloc(1000);
Valgrind says the bytes are “definitely” lost. Shouldn’t they just be “still reachable”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the allocated memory is not thread-local. It’s shared by all of the threads.
The variable is, on the other hand, thread local so once it’s out of scope that allocated memory will be definitely lost (if there are no copies of that pointer elsewhere.. and obviously there aren’t because valgrind reports definitely lost)
You have to
freeit.