delete calls so slow.On Windows XP or later, there's a mechanism to improve such situation, named low-fragmentation heap. You can enable this by the following code:
#if _MSC_VER >= 1400 typedef BOOL (WINAPI *fp_HeapSetInfo)( HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T); fp_HeapSetInfo hsi = (fp_HeapSetInfo)GetProcAddress( GetModuleHandle(_T("Kernel32")), "HeapSetInformation"); if(hsi) { ULONG flags = 2; HANDLE hHeap = (HANDLE)_get_heap_handle(); if(hsi(hHeap, HeapCompatibilityInformation, &flags, sizeof(flags))) { // MessageBox(NULL, _T("Wow, LFH is enabled!"), _T("Enabling LFH"), MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL); } #endif
Please note that _get_heap_handle function was introduced on Visual C++ 8.0 (Visual Studio 2005) so this code block should be ifndef-ed for earlier compilers.
PixelLive SDK Frequently Asked Questions
Basically, on Linux machine (but it's also true with future Mac OS X machine), we should explicitly specify the compiler to build the codes by CXX variable like the following commandline:
make CXX=g++33
Please check your compiler settings, without /GR option, you may happen to get such result. For more information, see Windows Development Notes.
In general, global variables are initialized before execution of some initialization codes and also before main(). Since String depends on initialization of some components, it should not be used before them and it could not be a global variable.
Anyway, if it could not be non-global variable, there is a way to make it fake-global variable:
String& getMyFakeGlobalVariable()
{
static String str;
return str;
}