Hi, <br>   I want to track down an memory problem and have something I don&#39;t understand. <br>In the following part, I create four vectors and destroy them. If I don&#39;t call KSPSolve, log tells me four Vec are created and four Vec are destroyed which I expect. But if I call KSPSolve, log tells me four Vec are created but only two are destroyed in that Stage? Does KSP refer the two vectors somewhere inside which make VecDestroy cannot destroy them? Does it create memory leak becase of that? Thanks. <br>
<br>    ierr=PetscLogStagePush(memoryWatch);CHKERRQ(ierr);<br>    MatGetVecs(*(pCSolverNeu-&gt;pK),&amp;x0,&amp;rhs); VecDuplicate(x0,&amp;(workVec[0]));VecDuplicate(x0,&amp;(workVec[1]));<br>    VecSetRandom(x0,randomctx);   <br>
    VecCopy(x0,workVec[0]);<br>    MatMult(*(pMGDataVec[0]-&gt;pA),x0,rhs);<br>   <br>    ierr=KSPSolve(ksp,rhs, workVec[0]);CHKERRQ(ierr);<br>    <br>    ierr=VecDestroy(&amp;x0);CHKERRQ(ierr);<br>    ierr=VecDestroy(&amp;rhs);CHKERRQ(ierr);<br>
    ierr=VecDestroy(&amp;workVec[0]);CHKERRQ(ierr);<br>    ierr=VecDestroy(&amp;workVec[1]);CHKERRQ(ierr);<br>    ierr=PetscLogStagePop();CHKERRQ(ierr);<br>