<div dir="ltr"><div dir="ltr">On Mon, Mar 9, 2020 at 3:47 PM Zane Charles Jakobs <<a href="mailto:Zane.Jakobs@colorado.edu">Zane.Jakobs@colorado.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi PETSc devs,</div><div><br></div><div>I have a C++ program written with PETSc (code available at <a href="https://github.com/DiffeoInvariant/NLTS/blob/master/examples/mutual_opt.cpp" target="_blank">https://github.com/DiffeoInvariant/NLTS/blob/master/examples/mutual_opt.cpp</a>), and if I run it with -malloc_debug and -malloc_dump enabled, PETSc says no memory is left unfreed at exit. However, running with valgrind --leak-check=full --show-leak-kinds=all gives me this leak summary: </div><div><br></div><div>LEAK SUMMARY:<br>==15364== definitely lost: 0 bytes in 0 blocks<br>==15364== indirectly lost: 0 bytes in 0 blocks<br>==15364== possibly lost: 0 bytes in 0 blocks<br>==15364== still reachable: 610,904 bytes in 8,246 blocks<br>==15364== suppressed: 0 bytes in 0 blocks</div><div><br></div><div>The information from --show-leak-kinds=all gives several blocks of the form (this is the last block printed; I've attached the full output from valgrind to this email)</div><div><br></div><div>==15364== 329,080 bytes in 3 blocks are still reachable in loss record 7 of 7<br>==15364== at 0x483CFAF: realloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)<br>==15364== by 0x7BDE1A7: ??? (in /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.1)<br>==15364== by 0x7BDE41C: ??? (in /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.1)<br>==15364== by 0x7BDE579: pci_device_get_device_name (in /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.1)<br>==15364== by 0x759CFC4: hwloc_look_pci (in /usr/local/petsc/arch-linux-cxx-debug/lib/libmpi.so.12.1.8)<br>==15364== by 0x7571D0B: hwloc_discover (in /usr/local/petsc/arch-linux-cxx-debug/lib/libmpi.so.12.1.8)<br>==15364== by 0x7571637: hwloc_topology_load (in /usr/local/petsc/arch-linux-cxx-debug/lib/libmpi.so.12.1.8)<br></div></div></blockquote><div><br></div><div>hwloc is definitely mallocing memory and not freeing it (not PETSc), but its really small.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>==15364== by 0x736780A: MPIR_Init_thread (in /usr/local/petsc/arch-linux-cxx-debug/lib/libmpi.so.12.1.8)<br>==15364== by 0x7367435: PMPI_Init_thread (in /usr/local/petsc/arch-linux-cxx-debug/lib/libmpi.so.12.1.8)<br>==15364== by 0x491CABA: PetscInitialize (in /usr/local/petsc/arch-linux-cxx-debug/lib/libpetsc.so.3.012.4)<br>==15364== by 0x724AB0E: nlts::io::Initialize(int*, char***, char const*, char const*) (io.cpp:126)<br>==15364== by 0x4023CB: main (mutual_opt.cpp:30)</div><div><br></div><div>The function nlts::io::Initialize that's referenced at the bottom is simply</div><div><br></div><div><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC121">PetscErrorCode <span>nlts::io::Initialize</span>(<span>int</span> *argc, <span>char</span> ***argv,</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC122"> <span>const</span> <span>char</span> file[],</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC123"> <span>const</span> <span>char</span> help[])</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC124"> {</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC125"> PetscFunctionBeginUser;</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC126"> <span>auto</span> ierr = <span>PetscInitialize</span>(argc, argv, file, help);<span>CHKERRQ</span>(ierr);</td>
</tr>
<tr>
</tr></tbody></table><table><tbody><tr><td id="gmail-m_-7804495519093650376gmail-LC127"> <span>PetscFunctionReturn</span>(ierr);</td>
</tr>
<tr>
</tr></tbody></table> }</div><div><br></div><div>Is valgrind actually detecting unfreed memory here, or is this something I don't need to worry about?</div><div><br></div><div>Thanks!</div><div><br></div><div>-Zane Jakobs<br></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>