memory leaks with pthread_key_delete

A

Alvaro

Hi!
I have a problem with this code:
#include <pthread.h>
#include <iostream.h>
int main(int argc, char** argv)
{
while(1)
{
pthread_key_t m_key;
if (pthread_key_create(&m_key,NULL))
cerr<<"Error en create"<<endl<<flush;
if (pthread_key_delete(m_key))
cerr<<"Error en delete"<<endl<<flush;
}
};

This code is leaking memory in each iteration and i don't know where is the
problem. This program is ran with Solaris Operation System, and the compiler
is SUN CC 6.0.

Thanks, Alvaro
 
A

Adam Fineman

Alvaro said:
Hi!
I have a problem with this code:
#include <pthread.h>
#include <iostream.h>
int main(int argc, char** argv)
{
while(1)
{
pthread_key_t m_key;
if (pthread_key_create(&m_key,NULL))
cerr<<"Error en create"<<endl<<flush;
if (pthread_key_delete(m_key))
cerr<<"Error en delete"<<endl<<flush;
}
};
Firstly, lose the semicolon after the closing brace of main().

Secondly, this query would be on topic on comp.programming threads.

- Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top