Visual Studio 2015具有严重错误,仅在Windows XP中会减少可用虚拟内存 [英] Visual Studio 2015 have critical error that decreasing available virtual memory just only in Windows XP

查看:107
本文介绍了Visual Studio 2015具有严重错误,仅在Windows XP中会减少可用虚拟内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用大量内存和线程的视频分析引擎.我们支持从XP,Win8.1,Win10到Linux的许多操作系统.

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.

大约两年前更改为Visual Studio 2015之后,XP(32bit)中出现了许多问题.

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;
}

下面的链接图像是vs2010和vs2015之间的测试结果图像. 内存测试vs2010 vs vs2015. 在Visual Studio 2015中,反复创建线程会导致Windows XP中的可用虚拟内存减少. 减少可用的虚拟内存会产生另一个大问题. 该错误无法处理异常,并弹出Dr.Watson错误消息.

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?

推荐答案

最近,我发现了新信息.
环境如下.

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

  1. 编译器:Visual Studio 2015
  2. 编译器选项:v140_xp,使用静态库

测试用例

  1. 测试用例1:创建和删除迭代线程
    这种情况下,物理内存和虚拟内存正在增加.
    因此,我认为线程创建和删除存在内存泄漏问题.
  2. 测试用例2:在新创建的线程中创建和删除迭代线程,以及分配和释放迭代内存.
    这种情况有些不同.
    虚拟和物理内存也在增加,但是虚拟内存的增长速度更快.我认为还有另一个问题,即新线程中的迭代内存分配导致仅减少虚拟内存!
  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!

这篇关于Visual Studio 2015具有严重错误,仅在Windows XP中会减少可用虚拟内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆