HELP on parmetis.Can any help to find an example to parallel distribute tetrahedral?My own code get some error from time to time

This is the error code.

Maximum memory used: 13179196 bytes
Current memory used: 5431868 bytes
***Memory realloc failed for cnbrpoolGet: cnbrpool. Requested size: 194608 bytes
MPI process (rank: 0) terminated unexpectedly

you can see that it doesn't use so much memory.My memory is big enough.Why it fail to realloc?

My code looks like this.
real_t ubvec = 1.05;
idx_t options[3] = {0, 0, 0};
idx_t wgtflag=0;
idx_t numflag=0;
idx_t ncon=1;
idx_t ncom=3;
idx_t nparts=allrank;
idx_t edgecut;
//I think the other parmeters are right.I can't understand the meaning of the parameters list above
//Can anyone tell me wheter there is some wrong with my call?
&wgtflag,&numflag, &ncon,&ncom,&nparts,
tpwgts,&ubvec,options, &edgecut, part,

RE: What is twpgts? Also, how is

What is twpgts?

Also, how is the mesh initially distributed among the processors?

RE: Thank you for your kind help.

real_t *tpwgts;
tpwgts =(real_t *)malloc(nparts*sizeof(real_t));