I am getting an occasional "C++ exception: std::bad_alloc at memory location" with the following code.

LPDIRECTSOUNDBUFFER8* ppDirectSoundBuffer;
ppDirectSoundBuffer = new LPDIRECTSOUNDBUFFER8[1];

This code is called on boot/init. I can run the app 10 times and this exception will get thrown about 1 time.

The randomness makes me think un-itialized variables. But as you can see, the code is pretty plain.

Any ideas?

Thank you

有帮助吗?

解决方案

So I figured this out. I was writing past the bounds of an array a few lines above this new call. Silly mistake =/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top