| 1. |
Why Does A Large Static Array Bloat My Executable File Size? |
|
Answer» GIVEN the declaration: CHAR[1024 * 1024] arr; the executable size increases by a megabyte in size. In C, this would not as arr would be stored in the BSS segment. In D, arr is not stored in the BSS segment because:
The following will be placed in BSS: __gshared byte[1024 * 1024] arr; as bytes are 0 initialized and __gshared puts it in the global data. There are similiar issues for float, double, and real static arrays. They are initialized to NaN (Not A NUMBER) values, not 0. The EASIEST way to deal with this issue is to allocate the array dynamically at run time rather than statically allocate it. Given the declaration: char[1024 * 1024] arr; the executable size increases by a megabyte in size. In C, this would not as arr would be stored in the BSS segment. In D, arr is not stored in the BSS segment because: The following will be placed in BSS: __gshared byte[1024 * 1024] arr; as bytes are 0 initialized and __gshared puts it in the global data. There are similiar issues for float, double, and real static arrays. They are initialized to NaN (Not A Number) values, not 0. The easiest way to deal with this issue is to allocate the array dynamically at run time rather than statically allocate it. |
|