Skip to content

Commit a13df3b

Browse files
committed
interfaces: Plug some memory leaks.
Signed-off-by: Matthew Emmett <[email protected]>
1 parent e609ab9 commit a13df3b

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

examples/advection_diffusion/ex1.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This example uses a vanilla SDC sweeper.
55
*/
66

7+
#include <fftw3.h>
8+
79
#include <pfasst.hpp>
810
#include <pfasst/sdc.hpp>
911
#include <pfasst/encap/vector.hpp>
@@ -35,4 +37,6 @@ int main(int argc, char **argv)
3537
sweeper->exact(q0, 0.0);
3638

3739
sdc.run();
40+
41+
fftw_cleanup();
3842
}

examples/advection_diffusion/ex2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* This example uses a (serial) multi-level SDC sweeper.
55
*/
66

7+
#include <fftw3.h>
8+
79
#include <pfasst.hpp>
810
#include <pfasst/mlsdc.hpp>
911
#include <pfasst/encap/vector.hpp>
@@ -69,5 +71,5 @@ int main(int argc, char **argv)
6971
mlsdc.set_duration(dt, nsteps, niters);
7072
mlsdc.run();
7173

72-
return 0;
74+
fftw_cleanup();
7375
}

examples/advection_diffusion/ex3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* controller.
88
*/
99

10-
#include <tuple>
10+
#include <fftw3.h>
1111

1212
#include <pfasst.hpp>
1313
#include <pfasst/mlsdc.hpp>
@@ -65,5 +65,5 @@ int main(int argc, char **argv)
6565
mlsdc.set_duration(dt, nsteps, niters);
6666
mlsdc.run();
6767

68-
return 0;
68+
fftw_cleanup();
6969
}

examples/advection_diffusion/fft.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ class FFT {
3333
{
3434
for (auto& x: workspaces) {
3535
auto* wk = std::get<1>(x);
36+
fftw_free(wk->wk);
3637
fftw_destroy_plan(wk->ffft);
3738
fftw_destroy_plan(wk->ifft);
38-
fftw_free(wk->wk);
3939
delete wk;
40-
// workspaces.erase(std::get<0>(x));
4140
}
4241
workspaces.clear();
43-
// workspaces.clear();
4442
}
4543

4644
workspace* get_workspace(int ndofs)

include/pfasst/interfaces.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace pfasst {
2727

2828
class ISweeper {
2929
public:
30-
virtual void setup(bool coarse=false) { }
3130
virtual ~ISweeper() { }
31+
virtual void setup(bool coarse=false) { }
3232

3333
virtual void sweep(double t, double dt) = 0; // XXX: this needs to be a templated
3434
virtual void predict(double t, double dt, bool initial) = 0; // XXX: this needs to be templated
@@ -40,6 +40,7 @@ namespace pfasst {
4040
public:
4141
// XXX: pass level iterator to these routines as well
4242
// XXX: these needs to be templated
43+
virtual ~ITransfer() { }
4344
virtual void interpolate(ISweeper *dst, const ISweeper *src,
4445
bool interp_delta_from_initial=false,
4546
bool interp_initial=false) = 0;

0 commit comments

Comments
 (0)