[petsc-users] pastix solver break at pastix_checkMatrix
Barry Smith
bsmith at mcs.anl.gov
Sun Jan 2 23:10:47 CST 2011
I just two distinct memory leaks in pastix.c (new file attached) for 3.1 (also fixed in petsc-dev).
Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastix.c
Type: application/octet-stream
Size: 28203 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110102/0daa964e/attachment-0001.obj>
-------------- next part --------------
On Jan 2, 2011, at 9:42 PM, Gong Ding wrote:
> 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