# FMOD\_DSP\_STATE and FMOD\_DSP\_ALLOC Behavior Across Plugin Instances & Systems

**URL:** <https://qa.fmod.com/t/fmod-dsp-state-and-fmod-dsp-alloc-behavior-across-plugin-instances-systems/22245>\
**Category:** FMOD Engine\
**Tags:** cpp, plugin-api\
**Created:** [October 31, 2024, 6:46am UTC](https://qa.fmod.com/t/fmod-dsp-state-and-fmod-dsp-alloc-behavior-across-plugin-instances-systems/22245 "2024-10-31T06:46:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkmarchan](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mkmarchan](https://qa.fmod.com/u/mkmarchan)\
**Post date:** [October 31, 2024, 6:46am UTC](https://qa.fmod.com/t/fmod-dsp-state-and-fmod-dsp-alloc-behavior-across-plugin-instances-systems/22245/1 "2024-10-31T06:46:49Z")

</div>

I’m working on an FMOD plugin and trying to make sure that all of our memory allocations / frees are routed through FMOD\_DSP\_ALLOC / FMOD\_DSP\_FREE. Some of the memory that the plugin is allocating is meant to be shared across multiple plugin instances and the instances may not have the same system object index in their FMOD\_DSP\_STATE struct. Additionally, since we don’t control the lifetime of the plugin, we don’t know which instance will be responsible for freeing the shared memory.

The behavior of FMOD\_DSP\_STATE / FMOD\_DSP\_ALLOC / FMOD\_DSP\_FREE is a bit unclear to me and I had a few questions about how to handle this scenario:

1. Will FMOD\_DSP\_STATE structs with the same systemobject index always point to the same FMOD\_DSP\_STATE\_FUNCTIONS struct?
2. Is #1 true or false if the FMOD\_DSP\_STATE structs have different systemobject indices?
3. Can memory allocated via FMOD\_DSP\_ALLOC made from one plugin instance be freed with FMOD\_DSP\_FREE from a different instance with the same systemobject index?
4. Is #3 true or false if the plugin instances have different systemobject indices?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [November 1, 2024, 12:12am UTC](https://qa.fmod.com/t/fmod-dsp-state-and-fmod-dsp-alloc-behavior-across-plugin-instances-systems/22245/2 "2024-11-01T00:12:24Z")

</div>

1. Yes.
2. No, the functions struct is stored in the System object, so you will see a different struct pointer for each system index.
3. Yes.
4. Yes.

The memory allocation functions plumbed into the `FMOD_DSP_STATE_FUNCTIONS` struct are global (not dependent on systemindex) so you can mix/match combinations of allocation and free.
