Valgrind显示以下示例代码的堆内存分配,
#include <stdio.h>
int main() {
int a = 7;
printf("%d", a);
return 0;
}
摘要报告是
==1825== HEAP SUMMARY:
==1825== in use at exit: 0 bytes in 0 blocks
==1825== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==1825==
==1825== All heap blocks were freed -- no leaks are possible
==1825==
==1825== For counts of detected and suppressed errors, rerun with: -v
==1825== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
示例代码没有任何堆内存分配。
有人可以解释为什么会在这里发生吗? 预先感谢.....