I'm considering converting an application that uses pthread_key_XXX methods for thread local storage over to using GCC's native support (the __thread attribute), since it should be significantly more efficient. However, I find myself at a loss to figure how this is intended to be used for dynamically sized variables... for example, what if I wanted to have each thread have a separate linked list of items it was supposed to process? There does not appear to be any way to clean these entries up at thread exit time, whereas pthread_key_create gives me the option of providing a cleanup function. pthread_cleanup_push() and _pop() are really not appropriate for this, as they are designed to be used within a single function's scope of execution. Am I missing something here? Is gcc's __thread support really only usable for variables that are not (or don't contain) pointers to dynamically allocated storage?