Visual Studio 2015 have critical error that decrea

2019-06-14 04:31发布

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?

1条回答
我想做一个坏孩纸
2楼-- · 2019-06-14 05:16

Recently, I find new information.
The environment is following.

  1. Compiler: Visual Studio 2015
  2. Compiler Option: v140_xp, use static lib

Test Case

  1. Test Case1: Iterative thread create and delete
    This case physical memory and virtual memory are increasing.
    So, I think there is memory leak problems thread creation and deleting.
  2. Test Case2: Iterative thread create and delete and iterative memory allocation and release in newly create thread.
    This case is a little bit different.
    Virtual and physical memory is also increasing, but virtual memory is increasing more faster. I think there is another problems that iterative memory allocation in new thread cause decreasing only virtual memory!
查看更多
登录 后发表回答