资源获取失败处理 [英] resource acquisition failure handling

查看:310
本文介绍了资源获取失败处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多年的编程,我没有遇到过合理的malloc或new失败的情况(也许是因为我的malloc确实是合理的),尽管我一直在检查它。

After years of programming, I havent had a situation where reasonable malloc or new would fail (maybe because my mallocs are trully reasonable), though I always check for it.

就我而言,应用程序应以适当的日志条目正常关闭(我希望)。在这种情况下您会怎么做?听到您的方法很有趣-您是在等待资源还是在关闭商店?

In my case, apps should gracefully (i hope) close with an appropriate log entry. What would you do in this case? Its interesting to hear your approach - do you wait for resources or close the shop?

推荐答案

如果动态分配失败-几乎没有任何操作可以处理这种情况。如果失败,则让应用崩溃。

There's pretty much nothing you can do if dynamic allocation fails- there are pretty much no operations written to handle that situation. If it fails, then just let the app crash.

这篇关于资源获取失败处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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