[Spread-users] Another way to leak

David Shaw dshaw at archivas.com
Mon Aug 30 11:42:16 EDT 2004


Here's a variation on the theme of the various leak generating
programs I've been posting.

This one is the simplest so far.  It doesn't even send any data.  All
it does is connect to spread, and then join and leave a group over and
over.  Membership messages are not even turned on.  It takes a while,
but you can watch spread's memory usage go up and up until the machine
starts swapping to death.  The memory is never returned.

David
-------------- next part --------------
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <sp.h>

int main(int argc,char *argv[])
{
  int mbox,err,count=0;
  char myself[MAX_GROUP_NAME];

  err=SP_connect(NULL,NULL,0,0,&mbox,myself);
  if(err!=ACCEPT_SESSION)
    {
      printf("Spread error %d on connect\n",err);
      exit(1);
    }

  for(;;)
    {
      err=SP_join(mbox,"hithere");
      if(err!=0)
	{
	  printf("Spread error %d on join\n",err);
	  break;
	}

      err=SP_leave(mbox,"hithere");
      if(err!=0)
	{
	  printf("Spread error %d on leave\n",err);
	  break;
	}

      count++;
      if(count%100000==0)
	printf("%d cycles completed\n",count);
    }

  err=SP_disconnect(mbox);
  if(err!=0)
    {
      printf("Spread error %d on disconnect\n",err);
      exit(1);
    }

  return 0;
}


More information about the Spread-users mailing list