On 12/02/2019 17:52, Vivek Subramanian wrote:
Well, okay, but Win32 code doesn #undef new at the start, and Microsoft themselves say to #define new for using CRT!
https://docs.microsoft.com/en-us/visualstudio/debugger/finding-memory-leaks-...
Actually, no, they don't -- at least not on that page. (In fact it specifically un-recommends that.) The technique shown there is to define a DBG_NEW macro. You then replace "new" with "DBG_NEW" whenever it appears in your application code. Hopefully this included the source of the leak. (You're doing this manually or via find/replace, not by #define new DBG_NEW.) It is true that in the past (and with MFC) they did recommend redefining new, but that has caveats. To minimise problems you were always supposed to do it only after all #includes, as I said in my other reply.