I am running into a memory leak that I am detecting through Visual Studio Debug Heap functions...
Hear is the call stack..
msvcr100d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 393 C++msvcr100d.dll!_nh_malloc_dbg_impl(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239 + 0x19 bytes C++msvcr100d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine) Line 302 + 0x1d bytes C++msvcr100d.dll!malloc(unsigned int nSize) Line 56 + 0x15 bytes C++msvcr100d.dll!operator new(unsigned int size) Line 59 + 0x9 bytes C++DirectX Demo.exe!std::_Allocate<std::_Container_proxy>(unsigned int _Count, std::_Container_proxy * __formal) Line 36 + 0x15 bytes C++DirectX Demo.exe!std::allocator<std::_Container_proxy>::allocate(unsigned int _Count) Line 187 + 0xb bytes C++DirectX Demo.exe!std::_String_val<wchar_t,std::allocator<wchar_t> >::_String_val<wchar_t,std::allocator<wchar_t> >(std::allocator<wchar_t> _Al) Line 469 + 0xa bytes C++DirectX Demo.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >() Line 550 + 0x58 bytes C++DirectX Demo.exe!Sound::Sound() Line 9 C++DirectX Demo.exe!Audio::LoadSound(std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > path, std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > ID, bool loop) Line 64 + 0xb bytes C++DirectX Demo.exe!MainMenuState::Init() Line 182 C++DirectX Demo.exe!StateManager::AddState(State * state) Line 13 + 0x23 bytes C++DirectX Demo.exe!Game::InitializeApp() Line 43 C++DirectX Demo.exe!Application::InitializeEngine(HINSTANCE__ * instance) Line 71 + 0xf bytes C++DirectX Demo.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nShowCmd) Line 106 + 0xf bytes C++DirectX Demo.exe!__tmainCRTStartup() Line 547 + 0x2c bytes CDirectX Demo.exe!WinMainCRTStartup() Line 371 Ckernel32.dll!768a3677() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!77139d42() ntdll.dll!77139d15()
When I step back through the stack to the first sign of code that is mine, it is pointing to an empty constructor...
DirectX Demo.exe!Sound::Sound() Line 9 C++
Sound::Sound(void){}
One more step back leads me to where the class object is being created.
> DirectX Demo.exe!Audio::LoadSound(std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > path,
std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > ID, bool loop) Line 64 + 0xb bytes C++
//-------------------------------------------------------------------------------// Perform per-frame update of audio//-------------------------------------------------------------------------------HRESULT Audio::LoadSound( std::wstring path, std::wstring ID, bool loop ){ HRESULT hr = S_OK; Wave wav; // Create and clear a sound Sound sound; //ZeroMemory( &sound, sizeof( Sound ) );***** BAD NEWS ****** // Use Wave object to open a .wav file // This will fill out a WAVEFORMATEXTENSIBLE and XAUDIO2_BUFFER structure if( FAILED( hr = wav.Open( path, sound ) ) ) return hr; // Store our sound m_sounds[ID] = sound; return S_OK;}
m_sounds is of the type
std::map< std::wstring, Sound > m_sounds
Basically I am really confused as to what I am not getting rid of and was looking to see if someone might be able to shed some light on this on.
REgards
Chad
[Edited by - chadsxe on August 21, 2010 9:22:32 AM]