Memory Management with CStringT

Class CStringT is a template class used to manipulate variable-length character strings. The memory to hold these strings is allocated and released through a string manager object, associated with each instance of CStringT. MFC and ATL provide default instantiations of CStringT, called CString, CStringA, and CStringW, which manipulate strings of different character types. These character types are of type TCHAR, char, and wchar_t, respectively. These default string types use a string manager that allocates memory from the process heap (in ATL) or the CRT heap (in MFC). For typical applications, this memory allocation scheme is sufficient. However, for code making intensive use of strings (or multithreaded code) the default memory managers may not perform optimally. This topic describes how to override the default memory management behavior of CStringT, creating allocators specifically optimized for the task at hand.

See Also

Concepts

CustomString sample