[Spread-users] More leak information

David Shaw dshaw at archivas.com
Wed Aug 25 12:53:33 EDT 2004


I've been digging into the fd and memory leak question a bit more, and
here is another test program.  All it does is connect to spread, then
join and leave a group 500 times, then disconnect.  I did this to show
that the memory problem happens even if there are no calls to
SP_multicast at all.

When you run it, spread's memory usage goes way up.  I stopped it at
636 megs, but presumably you can go further if you like.  Once
stopping the test program, the memory usage does not go down, and
spread is left with hundreds of open fds connecting to the local
socket (i.e. /tmp/4803).  Over time (several minutes), the fds are
closed one by one, but the memory usage does not go down.

Currently, the test program has membership messages turned on.  If you
turn off membership messages, the memory growth rate is radically
smaller.  I wonder if it is the membership message sitting in the
queue that is making the difference between the two runs.

As before, this is spread 3.17.2.

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

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

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

      for(i=0;i<500;i++)
	{
	  char groupname[MAX_GROUP_NAME];

	  sprintf(groupname,"%d",i);
	  err=SP_join(mbox,groupname);
	  if(err<0)
	    {
	      printf("Spread error %d on join\n",err);
	      break;
	    }

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

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

  /* Never reached */
  return 0;
}


More information about the Spread-users mailing list