# FSBank ERR\_MEMORY How to fix?

**URL:** <https://qa.fmod.com/t/fsbank-err-memory-how-to-fix/19008>\
**Category:** FMOD Studio\
**Tags:** csharp, cpp\
**Created:** [July 17, 2022, 4:35am UTC](https://qa.fmod.com/t/fsbank-err-memory-how-to-fix/19008 "2022-07-17T04:35:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CreatorsStudio](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/creatorsstudio/32/3590_2.png) [@CreatorsStudio](https://qa.fmod.com/u/CreatorsStudio)\
**Post date:** [July 17, 2022, 4:35am UTC](https://qa.fmod.com/t/fsbank-err-memory-how-to-fix/19008/1 "2022-07-17T04:35:23Z")

</div>

I am getting some mysterious error when use FSBANK\_BUILD()  
the FSBANK\_RESULT returns an error FSBANK\_ERR\_MEMORY  
I dont know why I am getting it  
if someone knows where I am wrong then please guide

Here is the C++ code

```
FSBANK_INITFLAGS InitFLAGS;
FSBANK_RESULT result;
string cachePath;
FSBANK_SUBSOUND subsound;
FSBANK_FORMAT format;
FSBank void SET_FSBANK_INIT_FLAG(int flag)
{
	InitFLAGS = flag;
}
FSBank void SET_FSBANK_CACHE_PATH(const char* path)
{
	cachePath = path;
}
FSBank int INIT_FSBANK(int quality)
{
	result = FSBank_Init(FSBANK_FSBVERSION_FSB5, InitFLAGS, quality, cachePath.c_str());
	return result;
}
FSBank void SetSubsoundNULL()
{
	subsound = { NULL };
}
FSBank void SUB_SOUND_FILE_PATHS(const char* Path)
{
	string sec = Path;
	const char* const s = sec.c_str();
	subsound.fileNames = &s;
}
FSBank void SUB_SOUND_OVER_RIDE_FLAG(int flag)
{
	subsound.overrideFlags = flag;
}
FSBank void SUB_SOUND_OVER_RIDE_QUALITY(int quality)
{
	subsound.overrideQuality = quality;
}
FSBank void SUB_SOUND_DESIRED_SAMPLE_RATE(int rate)
{
	subsound.desiredSampleRate = rate;
}
FSBank void SUB_SOUND_SAMPLE_NUMBER(int num)
{
	subsound.numFiles = num;
}
FSBank void FSB5_FSBANK_FORMAT(int formatENum)
{
	format = (FSBANK_FORMAT)formatENum;
}
FSBank int FSBANK_BUILD(int numberOfSubSounds, int quality, const char* SavePath)
{
	string saved = SavePath;
	const FSBANK_SUBSOUND* newSubsound = &subsound;
	FSBANK_RESULT result = FSBank_Build(newSubsound, (unsigned int)numberOfSubSounds, format, FSBANK_BUILD_DEFAULT | FSBANK_BUILD_DONTLOOP, (unsigned int)quality, NULL, saved.c_str());
	return result;
}

```

Here are the C# bindings

```
    const string dllName = "FSBankNative.dll";

    [DllImport(dllName)]
    public static extern void SET_FSBANK_INIT_FLAG(int flag);

    [DllImport(dllName)]
    public static extern void SET_FSBANK_CACHE_PATH(string path);

    [DllImport(dllName)]
    public static extern int INIT_FSBANK(int quality);

    [DllImport(dllName)]
    public static extern void SetSubsoundNULL();

    [DllImport(dllName)]
    public static extern void SUB_SOUND_FILE_PATHS(string Path);

    [DllImport(dllName)]
    public static extern void SUB_SOUND_OVER_RIDE_FLAG(int flag);

    [DllImport(dllName)]
    public static extern void SUB_SOUND_OVER_RIDE_QUALITY(int quality);

    [DllImport(dllName)]
    public static extern void SUB_SOUND_DESIRED_SAMPLE_RATE(int rate);

    [DllImport(dllName)]
    public static extern void SUB_SOUND_SAMPLE_NUMBER(int num);

    [DllImport(dllName)]
    public static extern void FSB5_FSBANK_FORMAT(int formatENum);

    [DllImport(dllName)]
    public static extern int FSBANK_BUILD(int numberOfSubSounds, int quality, string SavePath);

```

here is the C# code

```
        FSBankLib.SET_FSBANK_INIT_FLAG((int)FSBankLib.FSBANK_INITFLAGS.FSBANK_INIT_NORMAL);
        FSBankLib.SET_FSBANK_CACHE_PATH("G:/cache");
        FSBankLib.FSBANK_RESULT result = (FSBankLib.FSBANK_RESULT)FSBankLib.INIT_FSBANK(2);
        Console.WriteLine(result);
        FSBankLib.SetSubsoundNULL();
        FSBankLib.SUB_SOUND_FILE_PATHS("G:/u.wav");
        FSBankLib.SUB_SOUND_OVER_RIDE_FLAG((int)FSBankLib.FSBANK_BUILDFLAGS.FSBANK_BUILD_DISABLESYNCPOINTS);
        FSBankLib.SUB_SOUND_OVER_RIDE_QUALITY(1);
        FSBankLib.SUB_SOUND_DESIRED_SAMPLE_RATE(0);
        FSBankLib.SUB_SOUND_SAMPLE_NUMBER(1);
        FSBankLib.FSB5_FSBANK_FORMAT((int)FSBankLib.FSBANK_FORMAT.FSBANK_FORMAT_VORBIS);
        FSBankLib.FSBANK_RESULT result2 = (FSBankLib.FSBANK_RESULT)FSBankLib.FSBANK_BUILD(1,10,"G:/test");
        Console.WriteLine(result2);

```

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [July 24, 2022, 11:16pm UTC](https://qa.fmod.com/t/fsbank-err-memory-how-to-fix/19008/2 "2022-07-24T23:16:31Z")

</div>

I have not been able to reproduce this error, but I stopped short of making a custom dll and C# wrapper for FSBank myself.  
There are a couple of places that `FSBANK_ERR_MEMORY` could be coming from. If you could please upload a reproduction to your [FMOD Profile](https://fmod.com/profile#uploads) we can try hooking it up to our debug libs and see if we can narrow down what’s going wrong?
