【发布时间】:2018-06-18 15:49:26
【问题描述】:
我了解 内存泄漏 的定义,但找不到与 语义 或 语义内存泄漏 相关的任何内容以及与 @ 的区别987654321@.
内存泄漏示例:
#include <stdlib.h>
void function_which_allocates(void) {
/* allocate an array of 45 floats */
float *a = malloc(sizeof(float) * 45);
/* additional code making use of 'a' */
/* return to main, having forgotten to free the memory we malloc'd */
}
int main(void) {
function_which_allocates();
/* the pointer 'a' no longer exists, and therefore cannot be freed,
but the memory is still allocated. a leak has occurred. */
}
【问题讨论】:
-
你在哪里发现语义内存泄漏?有参考吗?
标签: memory memory-leaks storage heap-memory definition