I was just curious if there is a performance difference (e.g access time, speed, ...) between allocating static memory vs dynamic memory?
For example, if am reading data from a file, and storing them inside a huge buffer, what would be the differences between storing these data inside a static buffer vs a dynamic one?
The only speed difference should in the allocation/deallocation; access times should be equivalent. For a static array allocation/deallocation is nearly instant, for a dynamic array (I hope you use std::vector instead) a call to new/delete is required, the performance of which is not always the same, but always slower than for a static array. The unpredictability of performance for dynamic arrays can also be a reason to prefer static arrays in real-time systems.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
ALl dynamic arrays work off a pointer pointing to some allocated bit of memory.
This is an extra level of indirection that isn't there when using a fixed array. This will also have a small effect on performance.