# FlowField class memory management

**URL:** <https://discourse.channelflow.ch/t/flowfield-class-memory-management/107>\
**Category:** Programming\
**Created:** [November 18, 2020, 9:09pm UTC](https://discourse.channelflow.ch/t/flowfield-class-memory-management/107 "2020-11-18T21:09:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PratikAghor](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@PratikAghor](https://discourse.channelflow.ch/u/PratikAghor)\
**Post date:** [November 18, 2020, 9:09pm UTC](https://discourse.channelflow.ch/t/flowfield-class-memory-management/107/1 "2020-11-18T21:09:17Z")

</div>

Hi all,

I was doing a computation which involved calling a series of FlowFields in a loop and the minimal code was something as follows:

```auto
for (Real ta = 0; ta <= T; ta += n * dt) {
          for (Real tb = 0; tb <= T; tb += n * dt){
            string ua_name = "u" + t2s(ta, 1);
            string ub_name = "u" + t2s(tb, 1);
            FlowField ua("data/" + ua_name);
           FlowField ub("data/" + ub_name);

            // do something with ua and ub

          }
        }

```

I noticed that it crashed after some time. When I ran the `top’ command on my linux system, I realized that there might be some memory issues with the FlowField class of Channelflow 2.0.

For demonstration, I have created a minimal example for chflow FlowField memory leak ( [click here](https://drive.google.com/drive/u/0/folders/1u63CtC_bRFrnBxWzP2sFLBEmxhGSN5V8)), which I added to the examples directory. The example first generates a time-series for the Couette flow and then loops through the fields and adds them as ua + ub.

When I did some digging, I realized that there is no destructor in the current FlowField class. I am not sure how the memory is being managed and how this issue can be resolved.

Any help is appreciated. Thanks and take care.

---

<div class="post-metadata">

**Author:** ![jlangham](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jlangham](https://discourse.channelflow.ch/u/jlangham)\
**Post date:** [March 4, 2021, 6:26pm UTC](https://discourse.channelflow.ch/t/flowfield-class-memory-management/107/2 "2021-03-04T18:26:59Z")

</div>

Hi there,

I noticed this some time ago but never quite got to the bottom of it. However, for me at least I only got memory leaks when using an older MPI installation. There was a bug report here that may (or may not!) help:

> <https://github.com/epfl-ecps/channelflow/issues/12>
>
> Describe the bug
> Memory usage for parallel findsoln runs increases over time. This is becoming a problem for me during high resolution...
