79658782

Date: 2025-06-09 11:12:05
Score: 1
Natty:
Report link

static means to retain the value, so static array means that it value will be updated not restarted from the initial value (like int array). constant however just means its value is fixed, cannot be changed after initialization.

When you declare an array as static const int or const int, the computer puts it in a special part of the program called read-only memory, which means the array’s values are fixed and the memory is used right away when the program starts. (Its constant!) That’s why you see a big increase in memory use (RSS and PSS) immediately. But if you declare the array just as int (without const/static), it goes into a different part called the BSS segment. This part only reserves space but doesn’t actually use physical memory until the program starts to use the array. So, it looks like it uses much less memory because the memory is only given out when needed.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Arwa Abbas