libCEED
libCEED copied to clipboard
fluids: Fix memory leak
When running with -malloc_dump, PETSc reports quite a few memory leaks. Judging from the earliest report:
[ 0] 4992 bytes
[0] DMCreate() at /home/jrwrigh/software/petsc/src/dm/interface/dm.c:63
[0] CreateDM() at /home/jrwrigh/software/libCEED/examples/fluids/src/setupdm.c:22
I'm guessing the DM is being duplicated somewhere, but not being freed. Or, more likely, it's being duplicated, attached to another struct, and that struct isn't running DMDestroy on it.
Note that I can go all the way back to 7fb7f898 (#1143) and the problem is still present. So it's something very fundamental that is wrong.
FWIW, I fought this early on in Ratel and tracing these sorts of leaks gets easier if you thin out the data tracked in the structs. Lots of things can block the DM destruction, to include MATs and VECs
Yeah, might be easier to refactor, then see if the issues are still there than vice-versa.