0
votes

I've been under the impression that dynamic memory allocation is slower than static memory allocation, I then read about memory pools, but I'm confused

When we compare allocations, we are talking about using malloc vs initializing a variable. But then If one were to allocate a big array with malloc and access it, would we get the same performance as If we allocated it statically? Let's say you had:

int i[100];
j = malloc(sizeof(int) * 100);

// Would these two lines yield the same performance?
i[1] = 10;
j[1] = 100;

Thank you for reading...

1

1 Answers

0
votes

Memory is memory. Once's its allocated, it all behaves the same. Only the allocation is slower.