linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mehmet Tek <mtek@ade.com>
To: linux-c-programming@vger.kernel.org
Subject: Thread causing memory leaks...
Date: Fri, 19 Aug 2005 13:37:01 +0000 (UTC)	[thread overview]
Message-ID: <loom.20050819T152650-168@post.gmane.org> (raw)


Hi all,

After debugging for a number of hours, I found out that the very basics of my 
thread usage is causing memory leaks. (I checked it with mtrace and valgrind, 
they both say that there is memory leak.)

I have a very simple program below that leaks memory. Can anyone tell me if I 
am doing sth wrong, or is it actually some bug in the native thread 
implementation?

Any feedback would be appreciated...

Thanks,
Mehmet

PS: I am using Linux 2.4.21 (SuSE 9.0) with gcc 3.3.1 on a AMD64 machine.

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

#include <iostream>
#include <pthread.h>
#include <mcheck.h>

using namespace std;

void *thFunction(void *arg) {

  cout << " Thread started"  << endl;

  cout << " Thread ending"  << endl;

  return NULL;

}

int main() {

  pthread_t  th;

  //  mtrace();

  cout << " Spawning the thread" << endl;

  pthread_create(&th, NULL, thFunction, NULL);

  pthread_join(th, NULL);

  //  muntrace();

  return 0;
}



             reply	other threads:[~2005-08-19 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-19 13:37 Mehmet Tek [this message]
     [not found] <200508191714586.SM02404@037f27dd816a40c>
2005-08-22  8:36 ` Thread causing memory leaks Jean-Philippe Andriot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20050819T152650-168@post.gmane.org \
    --to=mtek@ade.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).