免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1776 | 回复: 2
打印 上一主题 下一主题

在HP UNIX上申请内存的时候,一个进程超过785M就不能创建线程,怎么解决呢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-05 09:46 |只看该作者 |倒序浏览
void * child(void *args)
{
        printf("child thread start\n";
        int tid = pthread_self();
        printf("thread %d enter\n", tid);
        printf("child thread end\n";
}

int main(void)
{
        printf("main thread start\n";
        for(;
        {
        pthread_t pt;
        int ret = pthread_create(&pt, NULL, child, NULL );
        printf("main thread create thread the ret =%d\n",ret);
        sleep(1);
        char *p1 = (char *)malloc( 5 * 1024 * 1024 );
        if( p1 != NULL )
        memset( p1,'1', 5 * 1024 * 1024 );
//      free( p1 );
        }
   printf("main thread exit\n";
   return 0;   
}
结果
thread 156 enter
child thread end
main thread create thread the ret =0
child thread start
thread 157 enter
child thread end
main thread create thread the ret =11
main thread create thread the ret =11
main thread create thread the ret =11

论坛徽章:
0
2 [报告]
发表于 2007-03-05 21:26 |只看该作者
这个貌似和你在HP-UX上还是别的unix上无关
你用 pthread_create 创建了 joinable 的线程,却不用 pthread_join 回收线程资源,到达线程数量上限了而不是内存上限

man pthread_create
man pthread_join
man pthread_attr

论坛徽章:
0
3 [报告]
发表于 2007-03-05 22:52 |只看该作者
HP-UX 上你要看一下
1 kernel 参数 (kctune): maxdsiz, max_thread_proc
2 swapinfo
3 ulimit
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP