【发布时间】:2017-11-05 03:13:26
【问题描述】:
我一直认为动态内存分配比静态内存分配慢,然后我阅读了内存池,但我很困惑
当我们比较分配时,我们谈论的是使用 malloc 与初始化变量。但是,如果使用 malloc 分配一个大数组并访问它,我们会获得与静态分配相同的性能吗?假设你有:
int i[100];
j = malloc(sizeof(int) * 100);
// Would these two lines yield the same performance?
i[1] = 10;
j[1] = 100;
感谢您的阅读...
【问题讨论】:
标签: c memory memory-management malloc allocation