# How do I delete an allocated array when I close the plugin?

**URL:** <https://iplug2.discourse.group/t/how-do-i-delete-an-allocated-array-when-i-close-the-plugin/826>\
**Category:** Uncategorized\
**Created:** [25 October 2023 21:46 UTC](https://iplug2.discourse.group/t/how-do-i-delete-an-allocated-array-when-i-close-the-plugin/826 "2023-10-25T21:46:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kallyn](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kallyn](https://iplug2.discourse.group/u/Kallyn)\
**Post date:** [25 October 2023 21:46 UTC](https://iplug2.discourse.group/t/how-do-i-delete-an-allocated-array-when-i-close-the-plugin/826/1 "2023-10-25T21:46:09Z")

</div>

My goal is to have an array that is some power of two in size so I can run it through an FFT algorithm. I would like to delete the array when I delete the plugin. I tried overriding the destructor of the IPlugProcessor to also delete the array, but I get an error because the other variables are inaccessible (mChannelData and mIOConfigs). Why does this happen? is there a keyword I am missing?

Alternatively, is there a better way to do FFT processing? I’m new to audio programming so bear with me

```auto
// updated destructor
MyPlugin::~MyPlugin()
{
  TRACE

  delete[] array;

  mChannelData[ERoute::kInput].Empty(true);
  mChannelData[ERoute::kOutput].Empty(true);
  mIOConfigs.Empty(true);
// ^^ each of these three give errors
}

```

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [30 October 2023 09:37 UTC](https://iplug2.discourse.group/t/how-do-i-delete-an-allocated-array-when-i-close-the-plugin/826/2 "2023-10-30T09:37:44Z")

</div>

The destructor of IPlugProcessor will still get called if you implement a destructor in your plugin.

Rather than use a C Style array, try using `std::vector<float> mArray`; This will manage the deallocation for you when it goes out of scope.

---

<div class="post-metadata">

**Author:** ![Kallyn](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kallyn](https://iplug2.discourse.group/u/Kallyn)\
**Post date:** [31 October 2023 00:05 UTC](https://iplug2.discourse.group/t/how-do-i-delete-an-allocated-array-when-i-close-the-plugin/826/3 "2023-10-31T00:05:14Z")

</div>

I was originally using them, but I was afraid that there might be a lot of unnecessary calculations happening downstairs that I could avoid by creating and operating my own arrays. Are there any unnecessary calculations that a vector would require? Are they negligible in this situation?
