解决错误 R6016 - 线程数据空间不足 [英] Resolving Error R6016 - Not enough space for thread data

查看:27
本文介绍了解决错误 R6016 - 线程数据空间不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的静态链接 Visual C++ 2012 程序偶尔会生成 CRTL 错误:R6016 - 线程数据空间不足".

My statically-linked Visual C++ 2012 program sporadically generates a CRTL error: "R6016 - Not enough space for thread data".

来自微软的最小文档说当一个新线程产生时会产生这个错误消息,但没有足够的内存可以分配给它.

The minimal documentation from Microsoft says this error message is generated when a new thread is spawned, but not enough memory can be allocated for it.

但是,我的代码仅在几个明确定义的情况下显式地产生一个新线程,这两种情况都没有发生在这里(尽管 Microsoft 库在内部确实很好地产生了线程).当程序刚刚存在于后台时,一位用户报告了此问题.

However, my code only explicitly spawns a new thread in a couple of well-defined cases, neither of which are occurring here (although certainly the Microsoft libraries internally spawn threads at well). One user reported this problem when the program was just existing in the background.

不确定它是否相关,但我没有覆盖默认的 1MB 保留堆栈大小或堆大小,并且我的程序使用的总内存通常很小(在具有 12GB 实际 RAM 的系统上为 3MB-10MB,其中一半以上未分配).

Not sure if it's relevant, but I haven't overridden the default 1MB reserved stack size or heap size, and the total memory in use by my program is usually quite small (3MB-10MB on a system with 12GB actual RAM, over half of which is unallocated).

这种情况很少发生(所以我无法追踪),而且已经在不止一台机器上报告过这种情况.我只在 Windows 8.1 上听说过这个,但我不会读太多.

This happens very rarely (so I can't track it down), and it's been reported on more than one machine. I've only heard about this on Windows 8.1, but I wouldn't read too much into that.

是否有一些编译器设置可能会影响此错误?还是编程错误?

Is there some compiler setting somewhere that might influence this error? Or programming mistake?

推荐答案

结果证明这是由调用 CreateThread 而不是 _beginthread 引起的.备注部分中的 Microsoft 文档指出 CreateThread 在使用 CRT 库时会导致冲突,事实上,一旦我们进行了更改,我们就再也没有看到该错误.

This turned out to be caused by calling CreateThread rather than _beginthread. Microsoft documentation in the Remarks section states that CreateThread causes conflicts when using the CRT library, and indeed, once we made the change, we never saw that error again.

这篇关于解决错误 R6016 - 线程数据空间不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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