137 为什么引用计数

BACKWARD FORWARD


为什么不是仅仅释放对象?

考虑库例程:

void MakeDatatype( nx, ny, ly, lz, MPI_Datatype *new ) 
{ 
MPI_Datatype newx1; 
MPI_Type_vector( ly, 1, nx, MPI_DOUBLE, &newx1 ); 
MPI_Type_hvector( lz, 1, nx*ny*sizeof(double), newx1, 
                  new ); 
MPI_Type_free( &newx1 ); 
MPI_Type_commit( new ); 
} 

没有MPI_Type_free( &newx1 ), 当释放new时,随后会很笨拙地释放newx1.


Copyright: NPACT BACKWARD FORWARD