问题描述
我正在处理一个应该从命令行使用以下语法的项目:
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++,有几个原因我不愿意争论.计算阶段将是高度象征性的(想想编译器),并将使用非常复杂的动态分配的数据结构.特别是,它不适合 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++ 垃圾收集器的经验?他们工作得好吗?
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.
这篇关于不释放内存是否可以接受的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)