On Sun, Aug 24, 2008 at 8:36 PM, Dee Ayy <dee.ayy@xxxxxxxxx> wrote: > I'm receiving the following error in a custom app: > > err:ntdll:RtlpWaitForCriticalSection section 0x110048 "heap.c: main > process heap section" wait timed out in thread 001a, blocked by 001c, > retrying (60 sec) Ahh, the heap.c seems to be from ::HeapFree http://msdn.microsoft.com/en-us/library/aa366701(VS.85).aspx This is now a C++ question. What's wrong with this code? I'm only calling ::HeapFree if I have a valid pointer on which to call it, no? A window message is handled with this code, and I would expect that it is the only window message being processed at this time. If that is not the case, is there a way to "ensure serialized access" at this point? I did not write GetTradeRecords. For example, Java has a "synchronized" block level command that I could just enclose the code below into a code block. if (g_pTrades != NULL) ::HeapFree(hHeap, 0, g_pTrades); BriefUserInfo bui; ::ZeroMemory(&bui, sizeof(bui)); int g_nTrades = 0; std::string str; std::string symbol; g_pTrades = apiPumping.GetTradeRecords(&bui, &g_nTrades); ... if (g_pTrades != NULL) ::HeapFree(hHeap, 0, g_pTrades); //Mental note: Add more debug assertions.