[petsc-users] Memory leak in snesnpc ?

Barry Smith bsmith at petsc.dev
Tue Aug 18 13:01:08 CDT 2020



> On Aug 18, 2020, at 12:14 PM, Adolfo Rodriguez <adantra at gmail.com> wrote:
> 
> I am suspecting that there is a memory leak in the implementation of non-linear preconditioners in PETSc.

   It is possible, in the configurations we test there are no memory leaks, but perhaps your configuration does something we do not test.

   Run just one or two time-steps with command line option -malloc_debug (for the latest PETSc release). It should print at the end any unfreed memory.

   What happens if you do not destroy the context at each time-step but keep it for all time-steps? Is that possible? Still a memory leak?

   Barry

> 
> When I use the following options I see the memory usage increase (using the windows process monitor) during consecutive time steps.
> 
>   PetscOptionsSetValue(NULL, "-snes_type", "qn");  
> PetscOptionsSetValue(NULL, "-snes_qn_monitor", "");
> PetscOptionsSetValue(NULL, "-snes_qn_scale_type ", "jacobian");
> PetscOptionsSetValue(NULL, "-npc_snes_max_it", max_it);
> PetscOptionsSetValue(NULL, "-npc_snes_type", "newtonls");
> PetscOptionsSetValue(NULL, "-npc_pc_factor_levels", ilu_level);
> PetscOptionsSetValue(NULL, "-npc_ksp_rtol", s_ksp_rtol);
> PetscOptionsSetValue(NULL, "-npc_snes_linesearch_type", "bt");
> PetscOptionsSetValue(NULL, "-npc_snes_linesearch_max_it", "5");
> 
> SNESSetFromOptions(snes);
> 
> I destroy the context after each time step
> 
> 
> However, if I don't use a non-linear preconditioner, ie., 
> 
>  PetscOptionsSetValue(NULL, "-snes_converged_reason", "");
> PetscOptionsSetValue(NULL, "-snes_type", "qn");
> PetscOptionsSetValue(NULL, "-snes_qn_monitor", "");
> PetscOptionsSetValue(NULL, "-snes_qn_scale_type ", "jacobian");  
>   SNESSetFromOptions(snes);  
> 
> Then everything works fine.
> 
> Am I missing something?
> 
> Thanks!
> Adolfo
> 



More information about the petsc-users mailing list