fixed hdf5 memory problems by flushing before mem hdf5 internally holds pointers to is destroyed externally