Skip to content

Commit

Permalink
Merge pull request #196 from ammarhakim/dbg-fem-poi
Browse files Browse the repository at this point in the history
Fixed memory leaks in fem_poisson
  • Loading branch information
manauref authored Sep 10, 2023
2 parents bd962f2 + 71fcd4a commit 81ef6ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions zero/fem_poisson.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ gkyl_fem_poisson_new(const struct gkyl_rect_grid *grid, const struct gkyl_basis
gkyl_array_copy(kSq_ho, kSq);
} else {
up->ishelmholtz = false;
kSq_ho = gkyl_array_new(GKYL_DOUBLE, 1, 1);
kSq_ho = gkyl_array_new(GKYL_DOUBLE, up->num_basis, 1);
gkyl_array_clear(kSq_ho, 0.);
}

Expand Down Expand Up @@ -314,7 +314,7 @@ void gkyl_fem_poisson_release(gkyl_fem_poisson *up)
#endif

gkyl_free(up->globalidx);
gkyl_free(up->brhs);
gkyl_array_release(up->brhs);
gkyl_free(up->kernels);
gkyl_free(up);
}
4 changes: 2 additions & 2 deletions zero/fem_poisson_perp.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ gkyl_fem_poisson_perp_new(const struct gkyl_range *solve_range, const struct gky
gkyl_array_copy(kSq_ho, kSq);
} else {
up->ishelmholtz = false;
kSq_ho = gkyl_array_new(GKYL_DOUBLE, 1, 1);
kSq_ho = gkyl_array_new(GKYL_DOUBLE, up->num_basis, 1);
gkyl_array_clear(kSq_ho, 0.);
}

Expand Down Expand Up @@ -367,7 +367,7 @@ void gkyl_fem_poisson_perp_release(struct gkyl_fem_poisson_perp *up)
gkyl_superlu_prob_release(up->prob);
#endif

gkyl_free(up->brhs);
gkyl_array_release(up->brhs);
gkyl_free(up->kernels);
gkyl_free(up->perp_range);
gkyl_free(up->globalidx);
Expand Down
6 changes: 6 additions & 0 deletions zero/superlu_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,11 @@ gkyl_superlu_prob_release(struct gkyl_superlu_prob *prob)
{
SUPERLU_FREE (prob->rhs);
SUPERLU_FREE (prob->perm_c);

for (size_t k=0; k<prob->nprob; k++) {
SUPERLU_FREE (prob->perm_r[k]);
Destroy_CompCol_Matrix(prob->A[k]);
gkyl_free(prob->A[k]);

if (prob->assigned_rhs)
Destroy_SuperMatrix_Store(prob->B[k]);
Expand All @@ -265,6 +267,10 @@ gkyl_superlu_prob_release(struct gkyl_superlu_prob *prob)
Destroy_SuperNode_Matrix(prob->L[k]);
Destroy_CompCol_Matrix(prob->U[k]);
}

gkyl_free(prob->B[k]);
gkyl_free(prob->L[k]);
gkyl_free(prob->U[k]);
}
StatFree(&prob->stat);
gkyl_free(prob->A);
Expand Down

0 comments on commit 81ef6ee

Please sign in to comment.