I read some more info about stack and heap memory. All the pros and cons in here: What and where are the stack and heap?
However i always have this question. Should i use stack or heap for my variable? Just now i have a struct which is ca 10kb in size.
- I'm going to use it globally in the whole program
- I know that max number of the necessary structs will be 1000. (totally 10MB)
- Sometimes i'll use only one of them so the rest 999 is empty.
- I'm not going to use any recurrence.
- The program is going to run 24/7 on linux(raspberry Pi with 512MB RAM) and i'll access single struct in 5 seconds interval.
What do you advice? should i allocate it on stack or heap? Both of them have advantages and disadvantages
Thanks in advance.