public inbox for
 help / color / mirror / Atom feed
* Windows XP memory leak ??? [innocent newbie :)]
@ 2008-04-23 14:51 sam copydata
  0 siblings, 0 replies; only message in thread
From: sam copydata @ 2008-04-23 14:51 UTC (permalink / raw)
  To: pthreads-win32


I'm working on a threaded project under Linux & Windows. This project
is almost developed under Linux and then ported to windows. When we
tried to check memory stability under windows we found some leaks
while there was none under Linux.

When program runs, it grows up in memory by 4 KB blocks only under
windows XP (home or pro version) but it do not moves under windows
server 2003 or under Linux.

After many tests i isolated this code which reproduce the leak of memory :

//////////////////////////////////////////////// main.cpp
#include <iostream>
#include <pthread.h>

using namespace std;

#ifdef WIN32
# define usleep Sleep
# include "crtdbg.h"
# include <Windows.h>

typedef struct toto_s toto_t;

struct toto_s
  int ok;

void    *testthread(void *a)
  toto_t *test;

  test = (toto_t *)a;
  cout << "thread créé" << endl;
   test->ok = 1;

  return NULL;

int main()
  pthread_t    thread;
  toto_t    *data;

  data = (toto_t *)malloc(sizeof(toto_t));
  data->ok = 0;
  for (int i = 100000; i; i--)
      if (pthread_create(&thread, NULL, testthread, (void *)data))
            cout << "erreur : impossible de créer le thread" << endl;
            return -1;
//       testthread(data);
      cout << "thread " << 100000 - i << " créé" << endl;
      while (!data->ok)
      data->ok = 0;

  return 0;

//////////////////////////////////////////////// End of main.cpp

I compile this code with prebuild version of pthread 2.7.0 or 2.8.0
with the same results.
 I tried to do it in many other ways always with the same memory leak.

If someone have an idea, it would be very welcome, I'm on this since 3 days. :(


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-23 14:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-23 14:51 Windows XP memory leak ??? [innocent newbie :)] sam copydata

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 read-only IMAP folder(s) and NNTP newsgroup(s).