mit-crpg/openmc — pull request #162 by nelsonag (2013-04-04 19:40:04+00:00)
Title: Addition of clear routines to significantly reduce Valgrind-reported memory leaks

I had been noticing an increase in memory usage after large OpenMC calculations. I decided to try and track down the problem with Valgrind. I found that the major contributors were due to the nuclear data not being properly deallocated (mostly where pointers were allocated, as opposed to when allocatables are allocated, of course). On the examples/simple problem, around 3.5MB was leaked simply because of the nuclear data objects.
To fix the problem, I added clear routines to the types that Calgrind said require them and called them in free_memory in global.F90.

Valgrind still reports some memory leaks (16 bytes, dealing with the dictionaries). I tried very hard to remove these apparent leaks, but I am unsure how else the leak could still be occurring and am therefore not confident that it is a true leak. In addiiton, Valgrind reports many 'conditional which depends on uninitialized values' errors, but these are all due to the xml-fortran package not providing default values for the xml object attributes. I decided against fixing these issues since it could have become a pretty big change to the xml-fortran package.

For info, the valgrind logs from before and after the changes (for both gnu 4.7.2 and intel 13) are provided at the following links:

GNU:
https://www.dropbox.com/s/9q8r2su3p3w5xgd/valgrind_gnu_errors_Before.txt
https://www.dropbox.com/s/4goh94b69j2royw/valgrind_gnu_errors_After.txt

Intel:
https://www.dropbox.com/s/fxzc38sd7tjy3a6/valgrind_intel_errors_Before.txt
https://www.dropbox.com/s/ohawuut9fc5fpet/valgrind_intel_errors_After.txt