仅在使用调试标志进行编译时,“虚拟内存耗尽:无法分配内存”

问题描述

我收到以下代码(error.cpp)的错误:

#include <map>
#include <functional>
#include <vector>

int main()
{
    std::map<
        int,std::map< std::string,std::map<std::string,std::string>
            > > >
            > > >
            > > >
            > > >
            > > >
            > > >
            > >                                         oups;

}

使用调试标志进行编译时:

g++ error.cpp -g -o error

我的系统是Ubuntu 18.04,其中g ++ 7.5.0作为VM运行。 RAM为5GB,交换为2.5GB。剩下的硬盘空间为1GB。

这正常吗?有毛病吗有限制吗?

以上代码将是“更精细”的替代方案吗? (c ++ 14)

解决方法

在该定义中您有8 + 7 + 6个字符串,对吗?因此,我想说的是,您手中拥有的是关系21。为什么不尝试:

constexpr const std::size_t my_arity = 21;
std::unordered_set<std::array<std::string,my_arity>> oups;

相反?

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...