   HEAP - Free Heap block, modified after it was freed
  Hi, I've recently had some trouble with this code and hoping someone could help just a tad, I normally spend ages trying to do it myself but it's getting abit annoying. Mainly I just want to know what exactly is going on, maybe from that I can solve it myself.The main error isHEAP[Diokonika.exe]: HEAP: Free Heap block bb6970 modified at bb6a78 after it was freedWindows has triggered a breakpoint in Diokonika.exe.During runtime windows throws a break point and highlights this linetemplate <class T> inline std::string to_string(const T& t){std::stringstream ss;ss << t; // <----- this linereturn ss.str();}Normally this works fine running once per frame hereif (m_setup.calculateFPS){m_fps.fps++;if (GetTickCount() - m_fps.time > 1000){m_fps.lastFps = m_fps.fps;m_fps.fps = 0;m_fps.time = GetTickCount();}m_fps.fps_str = to_string<int>(m_fps.lastFps);}None of this is a problem if I dont use my fonts class. Basically the problem occurs after I delete a font class from the heap.void CFontManager::Update(float elapsed){m_pLiveFonts->Iterate(true);while (m_pLiveFonts->Iterate() != NULL){m_pLiveFonts->GetCurrent()->Update(elapsed);if (m_pLiveFonts->GetCurrent()->markedForDeath == true)m_pLiveFonts->RemoveCurrentElement();}}The thing is I dont understand how this relates to the breakpoint being made during runtime, how are these related and how is this function causing a problem for my fps calculations.During runtime this is the errorbox that shows before I enter back to the debugging and see the errorWindows has triggered a breakpoint in Diokonika.exe.This may be due to a corruption of the heap, which indicates a bug in Diokonika.exe or any of the DLLs it has loaded.The call stack showsntdll.dll!77807dfe()  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] ntdll.dll!77871c93()  ntdll.dll!7783c43e()  ntdll.dll!77828752()  ntdll.dll!7787252a()  ntdll.dll!7783c26c()  ntdll.dll!77828752()  msvcr90d.dll!5e06103e()  msvcr90d.dll!5e06fd76()  msvcr90d.dll!5e06fb2f()  msvcr90d.dll!5e06fadc()  msvcr90d.dll!5e07b25b()  msvcr90d.dll!5e05d691()  msvcp90d.dll!5e0e92e5()  msvcp90d.dll!5e130894()  msvcp90d.dll!5e0ffb92()  msvcp90d.dll!5e0ffc1c()  msvcp90d.dll!5e0ffa70()  msvcr90d.dll!5dfdd496()  msvcr90d.dll!5dfdd496()  msvcp90d.dll!5e0fe4ef()  msvcp90d.dll!5e10a66f() >Diokonika.exe!to_string<int>(const int & t=61)  Line 54 + 0x14 bytesC++ Diokonika.exe!CEngine::Run()  Line 195 + 0x15 bytesC++ Diokonika.exe!WinMain(HINSTANCE__ * instance=0x00c00000, HINSTANCE__ * prev=0x00000000, char * cmdLine=0x00283461, int cmdShow=1)  Line 97C++ Diokonika.exe!__tmainCRTStartup()  Line 578 + 0x35 bytesC Diokonika.exe!WinMainCRTStartup()  Line 403C kernel32.dll!771c4911()  ntdll.dll!777fe4b6()  ntdll.dll!777fe489() Ive never really looked at the call stack before. This is the first time Ive had a error like this and from some googling I thought it would be relevant.I don't need an answer exactly just maybe some info on whats happeneing here. Am I releasing some memory wrong it screws up the stringsteam later? I dunno. Confused I am! :(Hope someone can shed some light for me! Thanks anyway~ Azenris   
  The debug heap checking mechanism checks for heap consistency whenever a heap operation is performed, either allocating or deallocating memory. This means that the actual cause of heap corruption usually occurred sometime before the breakpoint you see. In this case, std::stringstream probably allocates some memory to do it's job and this is the first chance the runtime had to check heap consistency. As the error tells you, you've written to some memory that was already freed and this probably occurs sometime since the last heap allocation or deallocation was made.   ;  Thanks, I spent more focus back on my font deletion. I rewrote it, made sure the iteration was in the right place and the right memory was being deleted. Seems to be working fine now. ty for the response.   