# Memory leak calling setStateInformation() on hosted VST3 plugin

**URL:** <https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660>\
**Category:** Audio Plugins\
**Created:** [February 7, 2019, 7:53pm UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660 "2019-02-07T19:53:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![getdunne](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/getdunne/32/2712_2.png) [@getdunne](https://forum.juce.com/u/getdunne)\
**Post date:** [February 7, 2019, 7:53pm UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/1 "2019-02-07T19:53:43Z")

</div>

I’m writing a plugin-host program, and I’ve found that on Windows (10, 64-bit) calling _setStateInformation()_ on an _AudioPluginInstance_ which wraps a VST3 plugin seems to leak 4.5k bytes of memory every time. VST2 plugins don’t have this issue.

Assuming this is due to a problem in my own code (which it probably is), I tried everything I could think of, but no luck. I have therefore set up a small demo project on GitHub at [https://github.com/getdunne/juce-wrapper](https://github.com/getdunne/juce-wrapper). Any assistance/advice would be hugely appreciated.

BTW I have verified that the problem persists even with JUCE v5.4.2, released only a few hours ago, and with versions 3.6.7 through 3.6.12 (latest) of the Steinberg VST3 SDK.

UPDATE: I think I found the problem, and have submitted a Pull Request [https://github.com/WeAreROLI/JUCE/pull/484](https://github.com/WeAreROLI/JUCE/pull/484).

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [February 7, 2019, 8:38pm UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/2 "2019-02-07T20:38:02Z")

</div>

On Linux, building with address sanitizer (`-fsanitize=address`) will enable leak checking. That’s how I’d start debugging this issue, assuming you can build your program on Linux.

Just reread your post - does it only leak on Windows?

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [February 7, 2019, 8:45pm UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/3 "2019-02-07T20:45:42Z")

</div>

Linux probably doesn’t help much when it’s about hosting a 3rd party VST plugin. Very few of those available for Linux…

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [February 7, 2019, 11:27pm UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/4 "2019-02-07T23:27:15Z")

</div>

Nothing to stop you building one of the juce demo plugins as a vst3 and using that for testing.

---

<div class="post-metadata">

**Author:** ![getdunne](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/getdunne/32/2712_2.png) [@getdunne](https://forum.juce.com/u/getdunne)\
**Post date:** [February 8, 2019, 1:27am UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/5 "2019-02-08T01:27:41Z")

</div>

I already did that before posting, and I’ve tested with commercial VST3 plug-ins as well. All have the same issue.

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 26, 2019, 9:47am UTC](https://forum.juce.com/t/memory-leak-calling-setstateinformation-on-hosted-vst3-plugin/31660/6 "2019-03-26T09:47:27Z")

</div>

> <https://github.com/WeAreROLI/JUCE/commit/e821dd9b8efdf89609ab938eec93abf85992217d>
