# FMOD::Studio::System::loadBankMemory randomly fails with FMOD\_ERR\_INVALID\_PARAM, despite seemingly being passed the same parameters

**URL:** https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551
**Category:** FMOD Studio
**Created:** [November 22, 2017, 7:48pm UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551 "2017-11-22T19:48:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![FredrikSvantesson](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@FredrikSvantesson](https://qa.fmod.com/u/FredrikSvantesson)
#### Post date: [November 22, 2017, 7:48pm UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/1 "2017-11-22T19:48:31Z")

</div>

Issue was due to me misunderstanding and 32-byte aligning buffer size rather than the actual memory address. Issue resolved.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [November 23, 2017, 6:02am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/2 "2017-11-23T06:02:47Z")

</div>

When using FMOD\_STUDIO\_LOAD\_MEMORY\_POINT, the buffer needs to be 32-bit aligned. Which would explain why you don’t get this error every time.

[https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD\_Studio\_System\_LoadBankMemory.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_Studio_System_LoadBankMemory.html#/)

Make sure to keep the buffer around, you can only free it after receiving a FMOD\_STUDIO\_SYSTEM\_CALLBACK\_BANK\_UNLOAD callback, otherwise use FMOD\_STUDIO\_LOAD\_MEMORY to create a copy.

[https://www.fmod.com/docs/api/content/generated/FMOD\_STUDIO\_LOAD\_MEMORY\_MODE.html](https://www.fmod.com/docs/api/content/generated/FMOD_STUDIO_LOAD_MEMORY_MODE.html)

---

<div class="post-metadata">

### Author: ![FredrikSvantesson](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@FredrikSvantesson](https://qa.fmod.com/u/FredrikSvantesson)
#### Post date: [November 23, 2017, 7:32am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/3 "2017-11-23T07:32:38Z")

</div>

> [@](#):
>
> When using FMOD\_STUDIO\_LOAD\_MEMORY\_POINT, the buffer needs to be 32-bit aligned. Which would explain why you don’t get this error every time.
> 
> [https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD\_Studio\_System\_LoadBankMemory.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_Studio_System_LoadBankMemory.html#/)
> 
> Make sure to keep the buffer around, you can only free it after receiving a FMOD\_STUDIO\_SYSTEM\_CALLBACK\_BANK\_UNLOAD callback, otherwise use FMOD\_STUDIO\_LOAD\_MEMORY to create a copy.
> 
> [https://www.fmod.com/docs/api/content/generated/FMOD\_STUDIO\_LOAD\_MEMORY\_MODE.html](https://www.fmod.com/docs/api/content/generated/FMOD_STUDIO_LOAD_MEMORY_MODE.html)

If you look at my original code sample, you’ll see that it actually is aligned correctly (it’s 32 bytes btw, not bits, but it uses a define anyway)

And yes, I am keeping it in memory

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [November 23, 2017, 8:38am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/4 "2017-11-23T08:38:53Z")

</div>

Can you try with the logging libs, they should provide more information on the cause.

---

<div class="post-metadata">

### Author: ![FredrikSvantesson](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@FredrikSvantesson](https://qa.fmod.com/u/FredrikSvantesson)
#### Post date: [November 23, 2017, 9:26am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/5 "2017-11-23T09:26:06Z")

</div>

Looks like FMOD seem to think that the data isn’t 32 byte aligned

[ERR] AsyncCommandTableShadow::system\_loadBankMemory : Error! FMOD\_STUDIO\_LOAD\_MEMORY\_POINT buffer is not 32-byte aligned!

However, I’m pretty sure that 800 bytes are aligned to 32 bytes?

I logged my variables just to be sure:  
BANK SIZE: 800, WAS 774, PADDED WITH 26

This only happens for this bank as well. The other banks are much larger and always loads correctly:

BANK SIZE: 12480, WAS 12474, PADDED WITH 6  
BANK SIZE: 5663456, WAS 5663456, PADDED WITH 0

---

<div class="post-metadata">

### Author: ![FredrikSvantesson](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@FredrikSvantesson](https://qa.fmod.com/u/FredrikSvantesson)
#### Post date: [November 23, 2017, 9:37am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/6 "2017-11-23T09:37:27Z")

</div>

Or wait, should the actual memory address be aligned to 32 even bytes? Not just the actual size… ?

---

<div class="post-metadata">

### Author: ![FredrikSvantesson](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@FredrikSvantesson](https://qa.fmod.com/u/FredrikSvantesson)
#### Post date: [November 23, 2017, 10:03am UTC](https://qa.fmod.com/t/fmod-loadbankmemory-randomly-fails-with-fmod-err-invalid-param-despite-seemingly-being-passed-the-same-parameters/13551/7 "2017-11-23T10:03:18Z")

</div>

Yup, that seemed to have been the case. My bad! And thank you for the support Cameron, very appreciated!
