map大小有限制?高手:帮忙测试一个程序

topgun topgun 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用STL库中的map容器,遇到以下问题:我想把200,0000条
记录放到map内存中处理,但是每次总是加载到中途(不到100万)
就报内存出错,我的运行环境是8G内存的AIX上,谢谢!

shell>xlC -q64 -g stltest.cc -o ./stltest
shell>./stltest


//================stltest.cc=================================================//
#pragma warning(disable:4786)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <map>
#include <algorithm>
using namespace std ;

int main(int argc,char *argv[])
{
typedef map<string,int> MHistItem ;
MHistItem map_all_pass ;

char key[20]="\0" ;
for(int i=0; i< 2000000 ; i ++ )
{
sprintf(key,"%d\0",i) ;
map_all_pass.insert( MHistItem::value_type( string(key), 1)) ;

if( i%10000==0 )
printf("load:%d\n" , i/10000*10000) ;
}
map_all_pass.clear() ;
printf("======hello world=======\n");
}
//====================================================================//
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
topgun
新手乐园 33,315 成员 41,769 内容