Hi

The startup of this program causes memory leak, doesn't it? What's the
reason?

Tested on FreeBSD-6.1 and 5.4 with the same effect.

On Linux work fine.

========================

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

void* mythread(void* arg)
{
      return NULL;
}


void threaded()
{

#define size 1

      int ret, i;

      for (i = 0; i < size; i++) {
          pthread_t t_id;
          pthread_attr_t pthread_attr;

          pthread_attr_init (&pthread_attr);
          pthread_attr_setdetachstate (&pthread_attr,
PTHREAD_CREATE_DETACHED);

          ret = pthread_create (&t_id, &pthread_attr, mythread, NULL);

          pthread_attr_destroy (&pthread_attr);

          if (ret)
              printf ("pthread_create() returned error value %d\n", ret);
      }
}


int main()
{
      int i;

      for (i = 0; i < 10000000; i++) {

          if (i % 1000 == 0)
              printf ("main() iteration: %d\n", i);

          threaded();
      }

      printf ("FINISHED.\n");

      sleep (3600);

      return 0;
}

==============================

--
Igor A. Valcov
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to