它是可以接受的不释放内存 [英] Is it acceptable not to deallocate memory

查看:129
本文介绍了它是可以接受的不释放内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是应该通过命令行中使用下面的语法项目:

I'm working on a project that is supposed to be used from the command line with the following syntax:

program-name input-file

该计划应该处理输入,计算一些东西吐出结果在标准输出上。

The program is supposed to process the input, compute some stuff and spit out results on stdout.

我选择的语言是C ++有几个原因,我不愿意争论。计算阶段将是极具象征意义的(想想编译器),并将使用pretty复杂的动态分配的数据结构。特别是,它不适合RAII风格的编程。

My language of choice is C++ for several reasons I'm not willing to debate. The computation phase will be highly symbolic (think compiler) and will use pretty complex dynamically allocated data structures. In particular, it's not amenable to RAII style programming.

我想知道,如果它是可以接受的忘记释放内存,因为我希望整个计算功耗小于可用内存和操作系统是免费回收所有内存在程序结束后一步(假设程序终止秒)。什么是你觉得这事吗?

I'm wondering if it is acceptable to forget about freeing memory, given that I expect the entire computation to consume less than the available memory and that the OS is free to reclaim all the memory in one step after the program finishes (assume program terminates in seconds). What are your feeling about this?

作为一个备份计划,如果有的话我的项目将需要为服务器或交互运行,我想,我可以随时改装垃圾收集到源$ C ​​$ C。有没有人有使用垃圾收集器对C ++的经验?难道他们的工作呢?

As a backup plan, if ever my project will require to run as a server or interactively, I figured that I can always refit a garbage collector into the source code. Does anyone have experience using garbage collectors for C++? Do they work well?

推荐答案

应该不会造成具体情况的任何问题描述的问题。

It shouldn't cause any problems in the specific situation described the question.

然而,这不完全是正常的。静态分析工具会抱怨它。最重要的是,它建立的坏习惯。

However, it's not exactly normal. Static analysis tools will complain about it. Most importantly, it builds bad habits.

这篇关于它是可以接受的不释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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