Cleaned up memory usage in gmx traj and trjconv
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 17 Apr 2017 14:40:12 +0000 (16:40 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 9 May 2017 10:09:25 +0000 (12:09 +0200)
commit953d3e7aa050a4a7076db723ebec14bf8d4c56a4
tree4545f448f5ae298091267d16d6ee899f66aed645
parent36837a55c067c971102dd3fbb1203d36b310823d
Cleaned up memory usage in gmx traj and trjconv

These have test coverage, so their memory leaks can show up in
Jenkins, so need fixing.

Removed the frame title from t_trxframe. This was only ever relevant
for the non-binary file formats, and was not really used consistently
there. For example, trjconv always constructed a title, because it
needs to do so if the file that it read was a binary trajectory file,
which is a frequent use case when writing a non-binary trajectory file
(e.g. export xtc to pdb). The g96 format was also handled differently
from gro and pdb, which was not necessary. Because sometimes a
non-binary conformation file is read and used to create a topology, a
symbol table entry was managed when it was not required when that file
was actually being treated as a trajectory file. Nowhere was a title
being read into a t_trxframe, and later written from that t_trxframe
in a different scope, so there is no need to store it.

Removed close_trj. This duplicated function makes it hard to implement
C-style cleanup that works properly and is maintainable without
leaking memory in one place or another.

Removed premature initialization of t_topology in trjconv. The initial
contents are over-written in read_tps_conf(). Documented that the caller
of that function must call done_top().

Reading g96 files was uselessly creating a symtab. This is only needed
if fr->atoms is valid, but if so then there would be a symtab to pass
in. fr->atoms is valid when we write, and in read_stx_conf, but this
is not the case for general trajectory-frame reading.

Memory allocated by TNG was leaking, so created free_wrapper() so
we can have an RAII guard for that.

Initialized some more pointers in trjconv.

Change-Id: I3c7ca63cc39f21c69810997a90ae2b45b6845263
64 files changed:
src/contrib/do_multiprot.c
src/contrib/do_shift.c
src/contrib/gmx_sdf.c
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/confio.cpp
src/gromacs/fileio/confio.h
src/gromacs/fileio/espio.cpp
src/gromacs/fileio/espio.h
src/gromacs/fileio/g96io.cpp
src/gromacs/fileio/g96io.h
src/gromacs/fileio/groio.cpp
src/gromacs/fileio/groio.h
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/pdbio.h
src/gromacs/fileio/tngio.cpp
src/gromacs/fileio/trxio.cpp
src/gromacs/fileio/trxio.h
src/gromacs/gmxana/anadih.cpp
src/gromacs/gmxana/gmx_covar.cpp
src/gromacs/gmxana/gmx_density.cpp
src/gromacs/gmxana/gmx_densmap.cpp
src/gromacs/gmxana/gmx_densorder.cpp
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_disre.cpp
src/gromacs/gmxana/gmx_do_dssp.cpp
src/gromacs/gmxana/gmx_dos.cpp
src/gromacs/gmxana/gmx_gyrate.cpp
src/gromacs/gmxana/gmx_hbond.cpp
src/gromacs/gmxana/gmx_helix.cpp
src/gromacs/gmxana/gmx_helixorient.cpp
src/gromacs/gmxana/gmx_hydorder.cpp
src/gromacs/gmxana/gmx_mdmat.cpp
src/gromacs/gmxana/gmx_mindist.cpp
src/gromacs/gmxana/gmx_msd.cpp
src/gromacs/gmxana/gmx_order.cpp
src/gromacs/gmxana/gmx_potential.cpp
src/gromacs/gmxana/gmx_principal.cpp
src/gromacs/gmxana/gmx_rms.cpp
src/gromacs/gmxana/gmx_rmsdist.cpp
src/gromacs/gmxana/gmx_rmsf.cpp
src/gromacs/gmxana/gmx_rotacf.cpp
src/gromacs/gmxana/gmx_rotmat.cpp
src/gromacs/gmxana/gmx_saltbr.cpp
src/gromacs/gmxana/gmx_sans.cpp
src/gromacs/gmxana/gmx_sorient.cpp
src/gromacs/gmxana/gmx_spol.cpp
src/gromacs/gmxana/gmx_tcaf.cpp
src/gromacs/gmxana/gmx_traj.cpp
src/gromacs/gmxana/gmx_trjcat.cpp
src/gromacs/gmxana/gmx_trjconv.cpp
src/gromacs/gmxana/gmx_trjorder.cpp
src/gromacs/gmxana/gmx_vanhove.cpp
src/gromacs/gmxana/gmx_velacc.cpp
src/gromacs/gmxpreprocess/genconf.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/mdlib/tpi.cpp
src/gromacs/tools/check.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/index.h
src/gromacs/topology/symtab.h
src/gromacs/trajectory/trajectoryframe.cpp
src/gromacs/trajectory/trajectoryframe.h
src/gromacs/utility/unique_cptr.h
src/programs/mdrun/md.cpp