Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed memory leaks in fem_poisson #196

Merged
merged 4 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading