我正在阅读堆和堆栈的使用情况,我对堆和动态分配的内存有疑问。
如何知道应用程序使用的堆内存的使用情况/可用性
我在动态分配的解释中总是看到的是这样的:
int *p;
p = (int*)malloc(sizeof(int));/* A space in the heap is allocated to store an int*/
p = (int*)malloc(sizeof(int));/* p now points to another space in the heap ; the first allocated space is lost, causing a memory leak*/
我理解/ *评论* /我在代码中写道但我不清楚第一个空格是“丢失”所以我提出了两个想法:
通过这种方式,对第一个想法的调用将通过删除字节的地址来更新列表,或者对于第二个更改标志。
感谢您的时间。