المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Visual C++ 6.0: Don't Let Memory Al******** Failures Crash Your Legacy STL Applicatio



C++ Programming
03-29-2009, 02:42 AM
Most C++ developers make extensive use of the Standard Template Library (STL) in their code. If you are one of them and are using STL and Visual C++ 6.0 directly out of the box, your application is at high risk of crashing under low memory conditions. The problem arises because checking for failure of operator new is such an uncommon practice. To make things worse, when new does fail, the response is not standard. Some ******** compilers return NULL while others throw an exception.In addition, if you are using STL in an MFC project, be aware that MFC has its own set of rules. This article discusses these problems, explains how the default behavior has changed in Visual C++ .NET 2003, and outlines the changes you must make if you're using Visual C++ 6.0 so that you can safely use the STL when operator new fails.

James Hebben

<a href="http://msdn.microsoft.com/magazine/21882833-6c9e-47b8-af53-2d9d79d8e594">MSDN Magazine September 2003