[petsc-users] Question about GAMG and memory use

Randall Mackie rlmackie862 at gmail.com
Wed Mar 4 19:45:53 CST 2015

In my application, I am repeatedly calling KSPSolve with the following options:

-ksp_type gmres \
-pc_type gamg \
-pc_gamg_type agg \
-pc_gamg_agg_nsmooths 1\

each call is after the matrix and right hand side have been updated.

This works well in the sense that it solves the system in a reasonable number of steps, however, I have noticed that the memory footprint of the application increases by about 500 Mbytes after each call to KSPSolve (this is a big problem), and after several calls, I've maxed out the memory.

Is this expected behavior?

I've combed through my code looking to make sure I don't have any memory leaks, and so far I haven't found any (doesn't mean there are not there).

However, when I use another PC, like jacobi, just to compare, I don't see this memory issue, or if I comment out that call to KSPSolve (there is a lot of other stuff going on in the code besides this call), I don't see this issue.

I've tried to destroy the KSP after each solve and recreate it each time, but there still seems to be some memory getting added.

I've tried to distill this down to a smaller problem and test program, but so far I have been unsuccessful.

Is there a way to completely release the memory associated with the GAMG preconditioner after a call to KSPSolve?

Any other suggestions for tracking this down? I've run out of ideas.

Thanks in advance,


More information about the petsc-users mailing list