avatar
linux下跑得正常Unix下出错# Unix - 噫吁兮,危乎高哉
s*s
1
用GDB调试过
我得程序流程大致如此:
我有个数组,类型是自己定义得,刚开始我要把这个数组
得所有元素用读进来得二进制文件数据初始化
现在问题是,在前N个循环都正常,可是到n+1个数组
初始化时候在
m_pData = new double[size] 时出问题,程序执行这一行
就立即退出了,所以我看不出问题,一般来说我可以判断
m_pdata是否为空,是不是?但是现在都论不到我这一步
判断。
btw,我得数据很大,比较占内存,但是1G的内存应该够的,
因为我的linux服务器上就是这么多,这台SUN服务器内存
不比这个少。
avatar
s*s
2
从Linux跑的进程来看,大概需要250M内存

【在 s*****s 的大作中提到】
: 用GDB调试过
: 我得程序流程大致如此:
: 我有个数组,类型是自己定义得,刚开始我要把这个数组
: 得所有元素用读进来得二进制文件数据初始化
: 现在问题是,在前N个循环都正常,可是到n+1个数组
: 初始化时候在
: m_pData = new double[size] 时出问题,程序执行这一行
: 就立即退出了,所以我看不出问题,一般来说我可以判断
: m_pdata是否为空,是不是?但是现在都论不到我这一步
: 判断。

avatar
p*g
3
write a simple piece of test code, just try to new all the mem u need see if i
t will crash the code.
Another way is the catch the throw from new
try { aData = new double{size}; }
catch (std::bad_alloc&) { cerr<Yet another way is the use the new's handler, it and its usage are declared in
as
typedef void (*new_handler)();
new_handler set_new_handler(new_handler p) throw();
you will need to use it this way
#include
// function to call if opera

【在 s*****s 的大作中提到】
: 从Linux跑的进程来看,大概需要250M内存
avatar
c*r
4
run "limit" and see if "datasize" is limited

【在 s*****s 的大作中提到】
: 用GDB调试过
: 我得程序流程大致如此:
: 我有个数组,类型是自己定义得,刚开始我要把这个数组
: 得所有元素用读进来得二进制文件数据初始化
: 现在问题是,在前N个循环都正常,可是到n+1个数组
: 初始化时候在
: m_pData = new double[size] 时出问题,程序执行这一行
: 就立即退出了,所以我看不出问题,一般来说我可以判断
: m_pdata是否为空,是不是?但是现在都论不到我这一步
: 判断。

avatar
s*s
5
真够专业,试试看

【在 p******g 的大作中提到】
: write a simple piece of test code, just try to new all the mem u need see if i
: t will crash the code.
: Another way is the catch the throw from new
: try { aData = new double{size}; }
: catch (std::bad_alloc&) { cerr<: Yet another way is the use the new's handler, it and its usage are declared in
: as
: typedef void (*new_handler)();
: new_handler set_new_handler(new_handler p) throw();
: you will need to use it this way

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。