[uCsimm] simpler memory leak example

From: David Beckemeyer (david@corp.earthlink.net)
Date: Mon Jul 17 2000 - 14:52:41 EDT


Here's a simpler program that doesn't use stdio that consumes
all system memory over time using malloc/free. With the sleep()
call in there you can watch it consue memory (with ps). If you
remove the sleep() call it will immediately hang/crash uClinux
(uCsimm).

Is this a known probklem? Is there a fix?

This again is with 2.0.381pre5 (from the Rt-Control CD):

----------------------------------------------------------------

#define MEMSIZ 512

extern char *malloc (int x);

main ()
{
  char *p;
  int i;

  i = 0;
  do
    {
      p = malloc (MEMSIZ);
      if (p)
        free (p);
      i++;
      sleep (5);
    }
  while (p);
  printf ("failed after %d iterations\n", i);
  perror ("malloc");
  exit (1);
}
----------------------------------------------------------------
This message resent by the ucsimm@uclinux.com list server http://www.uClinux.com/



This archive was generated by hypermail 2b30 : Sun Apr 07 2002 - 00:01:37 EST