I am working with large arrays in C for numerical calculations.
Within one of the functions I make use of some temporary local (disposable) arrays. Normally I would just declare these as
When you declare a variable local to the method you are working with automatic allocated variables which go on the stack and unfortunately the stack size is limited. Using
malloc means that the variable will be allocated on heap and the time difference is what you pay for that dynamic allocation.
I see two possible solutions:
staticglobal array (and reuse it when necessary) so that the compiler will be able to optimize accesses to it