Skip to content
Snippets Groups Projects
Commit 1e8a1bc5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Clean up memory from the particle at the end of a run. Helps with sanitizer work.

parent 61b92384
No related branches found
No related tags found
2 merge requests!310Star particles and gparts links over MPI,!304Star particle infrastructure
......@@ -162,4 +162,22 @@ __attribute__((always_inline)) INLINE void cache_read_particles(
#endif
}
/**
* @brief Clean the memory allocated by a #cache object.
*
* @param c The #cache to clean.
*/
static INLINE void cache_clean(struct cache *c) {
if (c->count > 0) {
free(c->x);
free(c->y);
free(c->z);
free(c->m);
free(c->vx);
free(c->vy);
free(c->vz);
free(c->h);
}
}
#endif /* SWIFT_CACHE_H */
......@@ -2381,7 +2381,7 @@ void engine_collect_kick(struct cell *c) {
integertime_t ti_end_min = max_nr_timesteps;
/* Only do something is the cell is non-empty */
if (c->count != 0 || c->gcount != 0) {
if (c->count != 0 || c->gcount != 0 || c->scount != 0) {
/* If this cell is not split, I'm in trouble. */
if (!c->split) error("Cell is not split.");
......@@ -3555,6 +3555,8 @@ void engine_compute_next_snapshot_time(struct engine *e) {
*/
void engine_clean(struct engine *e) {
for (int i = 0; i < e->nr_threads; ++i) cache_clean(&e->runners[i].par_cache);
free(e->runners);
free(e->snapshotUnits);
free(e->links);
scheduler_clean(&e->sched);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment