[petsc-dev] Inquiry about PETSc Memory Accumulation Issue and Undefined Reference to `petscgarbagecleanup_`

Wang Lei workPCn1 at outlook.com
Sun Sep 28 22:20:51 CDT 2025


Dear PETSc Development Team,

I hope this message finds you well.

I am writing to seek your technical assistance regarding two related issues I have encountered while using PETSc in my application.

## 1. Memory Accumulation Issue

My application experiences gradual memory accumulation when performing multiple successive simulations. I've observed that PETSc objects (vectors, matrices, etc.) are not being completely cleaned up between simulation runs, even though I call the appropriate destroy functions.

Could you please advise:
- Are there any known issues with memory accumulation in repeated PETSc usage scenarios?
- What would be the recommended approach to ensure complete cleanup between multiple simulation cycles?
- Are there any internal cleanup routines that should be called periodically?

## 2. Undefined Reference to `petscgarbagecleanup_`

While investigating the memory issue, I came across references to the `petscgarbagecleanup_` function in documentation, which appears to be tagged as a "developer" function. However, I'm unable to link against this function in my build.

Here's what I've tried:
- Verified PETSc installation and basic functionality
- Checked for the symbol in libpetsc.so using `nm -gA` - the function is not present
- Tried rebuilding PETSc with `--with-debugging=0` configuration option
- Ensured proper compiler and environment consistency

My environment:
- PETSc Version: 3.23
- Operating System: Ubuntu
- Compiler: Intel OneAPI with MPI and MKL
- Installation Method: Source Code from git
- Configuration options used: ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpiifort --prefix=/home/icer/petsc-3.23 --with-scalar-type=complex --download-slepc=yes --download-mumps=yes --with-scalapack-dir=$MKLROOT --download-parmetis=yes --download-metis=yes --download-arpack=yes --force --with-debugging=0

Questions:
- Is `petscgarbagecleanup_` a function that requires special configuration flags to be available?
- Are there alternative functions or approaches to force comprehensive garbage collection in PETSc?
- Could this be related to my specific PETSc configuration?

I would greatly appreciate any insights or suggestions you might have on resolving these issues. The memory accumulation is particularly critical for my long-running application workflows.

Thank you for your time and assistance.

Best regards,

Lei Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20250929/1346f332/attachment.html>


More information about the petsc-dev mailing list