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

Fix memory issue in VectorInterpolator #247

Merged
merged 1 commit into from
Nov 15, 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
14 changes: 12 additions & 2 deletions lib/algo/manifold_interp/VectorInterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,29 @@ VectorInterpolator::VectorInterpolator(std::vector<Vector*> parameter_points,
if (i == d_ref_point)
{
d_rotated_reduced_vectors.push_back(reduced_vectors[i]);
d_rotated_reduced_vectors_owned.push_back(false);
}
else
{
Vector* Q_tA = rotation_matrices[i]->transposeMult(reduced_vectors[i]);
d_rotated_reduced_vectors.push_back(Q_tA);
d_rotated_reduced_vectors_owned.push_back(true);
}
}
}

VectorInterpolator::~VectorInterpolator()
{
for (auto v : d_rotated_reduced_vectors)
delete v;
CAROM_VERIFY(d_rotated_reduced_vectors.size() ==
d_rotated_reduced_vectors_owned.size());

for (int i = 0; i < d_rotated_reduced_vectors.size(); i++)
{
if (d_rotated_reduced_vectors_owned[i])
{
delete d_rotated_reduced_vectors[i];
ckendrick marked this conversation as resolved.
Show resolved Hide resolved
}
}

for (auto v : d_gammas)
delete v;
Expand Down
2 changes: 2 additions & 0 deletions lib/algo/manifold_interp/VectorInterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class VectorInterpolator : public Interpolator
*/
std::vector<Vector*> d_rotated_reduced_vectors;

std::vector<bool> d_rotated_reduced_vectors_owned;

/**
* @brief The reduced elements in tangential space.
*/
Expand Down