[petsc-users] pastix solver break at pastix_checkMatrix

Gong Ding gdiso at ustc.edu
Sun Jan 2 21:42:01 CST 2011


Dear  Barry,

It seems the patch will cause memory leak.

when  valOnly is false, memory will be allocated for colptr, row and values. 

99:  if (!valOnly){
100:   ierr = PetscMalloc(((*n)+1) *sizeof(PetscInt)   ,colptr );CHKERRQ(ierr);
101:   ierr = PetscMalloc( nnz     *sizeof(PetscInt)   ,row);CHKERRQ(ierr);
102:   ierr = PetscMalloc( nnz     *sizeof(PetscScalar),values);CHKERRQ(ierr);


But at the end of function MatConvertToCSC

186:    ierr = PetscMemcpy(*colptr,tmpcolptr,(*n+1)*sizeof(PetscInt));CHKERRQ(ierr);
187:    ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscInt),row);CHKERRQ(ierr);
188:   ierr = PetscMemcpy(*row,tmprows,((*colptr)[*n]-1)*sizeof(PetscInt));CHKERRQ(ierr);
189:    ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscScalar),values);CHKERRQ(ierr);
190:    ierr = PetscMemcpy(*values,tmpvalues,((*colptr)[*n]-1)*sizeof(PetscScalar));CHKERRQ(ierr);

memory will be allocated again. 
Which means when code call MatConvertToCSC next time, the memory allocated at line 100-102 will be lost.

Will you please fix this problem? i.e. check the *colptr, *row and *values, when they are not empty, skip the memory allocation
at line  100-102.

Yours
Gong Ding
 


More information about the petsc-users mailing list