I am developing video analytics engines, which uses a lot of memory and threads. We support many Operating Systems from XP, Win8.1, Win10 to Linux.
After changing to Visual Studio 2015 about two years ago, there were many issues in XP(32bit).
The most important issue was "Decreasing available virtual memory". And interest thing was that physical memory is stable (not increasing). To find the cause, we ran many experiments over several months and we finally concluded that there was a compiler bug.
// project setting : vs2015, 32bit, use static lib, v140_xp
#include <vector>
#include <afxwin.h>
UINT AvailableVMShortageTestThread(LPVOID param)
{
// Do Nothing!
return 0;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
while (1) {
// Create test thread 20000 times!
for(int i = 0; i < 20000; i++) {
CWinThread* thread_ptr = AfxBeginThread (AvailableVMShortageTestThread, 0, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
thread_ptr->ResumeThread();
WaitForSingleObject (thread_ptr->m_hThread, INFINITE);
}
// Display available virtual memory
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
printf("ullAvailVirtual:%dMB\n",statex.ullAvailVirtual / (1024 * 1024));
}
return nRetCode;
}
Following linked image is test result image between vs2010 and vs2015. memory test vs2010 vs vs2015. In Visual Studio 2015, Creating thread repeatedly cause decreasing available virtual memory in Windows XP. Decreasing available virtual memory generate another big problems. That error cannot handle exception and pop up Dr. Watson error message.
Do you know any solutions?