From: saouter@dyonisos.irit.fr (Yannick SAOUTER)
Newsgroups: comp.parallel.pvm
Subject: Help with malloc in PVM
Date: 28 May 1999 13:05:31 GMT
Organization: IRIT, UPS TOULOUSE France
Sender: saouter@dyonisos (Yannick SAOUTER)
Message-Id: <7im4ar$a1p@irit1.irit.fr>
Xref: ukc comp.parallel.pvm:8443


Hello, I have designed a program with
the PVM library. It works on the classical
master slave scheme and there is exchange
of millions of messages from the slaves
to the master. However my master program
run out of memory after a while. My
receiving procedure is the following one:

char *recevoir_chaine(int i)
{
  char *buf;
  int bufid,longbuf;

  printf("Coucoua %d\n",_bytes_used);
  bufid=pvm_recv(tid[i],-1);
  printf("Coucoub %d\n",_bytes_used);
  pvm_bufinfo(bufid,&longbuf,(int *)0, (int *)0);
  buf=(char *)malloc((longbuf+1)*sizeof(char));
  printf("Coucouc %d\n",_bytes_used);
  pvm_upkstr(buf);
  printf("Coucoud %d\n",_bytes_used);
  pvm_freebuf(bufid);
  printf("Coucoue %d\n",_bytes_used);
  return buf;
}

where i is the tid of one slave. The printf are for debug
only and _bytes_used is an extern long generated by the
GNU malloc indicating the size taken in malloc structure
by the prog. What happens exactly is that most of the time
the receiving structures remain in a quasi constant area but
there is sometimes peaks of allocation generated by pvm_recv
which are not freed by pvm_freebuf and never reused after. This
makes the size of allocations to diverge and my program to run out
of memory. Here is a sample of an execution:

Coucoua 80616
Coucoub 88808
Coucouc 88840
Coucoud 88840
Coucoue 80648
Coucou5 80648
Coucou1 80648
Coucou2 80648
Coucou3 80616
Coucou5 80616
Coucou4 80616
Coucoua 80616
Coucoub 97000
Coucouc 97032
Coucoud 97032
Coucoue 88840
Coucou5 88840
Coucou1 88840
Coucou2 88840
Coucou3 88808
Coucou5 88808
Coucou4 88808
Coucoua 88808
Coucoub 178920
Coucouc 178952
Coucoud 178952
Coucoue 170760
Coucou5 170760
Coucou1 170760
Coucou2 170760
Coucou3 170728
Coucou5 170728
Coucou4 170728
Coucoua 170728
Coucoub 178920
Coucouc 178952
Coucoud 178952
Coucoue 170760
Coucou5 170760

The others Coucou are tags elsewhere in the program. Moreover the size
of the messages is quite small (several hundreds of characters) and so
I can't figure why pvm requires sometimes more than 100 Kb to receive
the message. Has anybody encountered this kind of problems ?
Alternatively, would anybody have a receiving primitive with no
allocation divergence.

Thanks in advance for any hint.

