在C中调用APORT:它会释放堆内存吗?
在C中调用Abort()将导致该过程的异常终止。我可以通过在线资源找到它不会关闭打开文件,可能不会删除临时文件,也可能不会冲洗流缓冲区。动态分配的内存(通过malloc()函数分配)怎么样?他们被收回了吗?
Calling abort() in C will cause abnormal termination of the process. I could find through online resources that it does not close open files, may not delete temporary files and may not flush stream buffer. How about dynamically allocated memory (allocated through malloc() function)? Are they reclaimed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当程序终止(在正常的,托管C的实现中)时,程序所使用的内存将释放。它是通过
abort()
还是通过普通出口终止的都没关系。如果您处于一个模糊(和敌对的)嵌入式系统中,则可能会发现规则不同,但是(AFAIK)即使在独立实现方面也是不寻常的,因为在程序退出时,不会发布内存,而不论如何如何它退出。
When a program terminates (in a normal, hosted implementation of C), the memory the program used is freed. It doesn't matter whether it terminates via
abort()
or via a normal exit.If you're on an obscure (and hostile) embedded system, you might find the rules are different, but it is (AFAIK) unusual, even in freestanding implementations, for the memory not to be released when the program exits, regardless of how it exits.