Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 09, 2017 Static array size? | ||||
---|---|---|---|---|
| ||||
Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager. |
February 09, 2017 Re: Static array size? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | V Thu, 09 Feb 2017 11:22:28 +0000 Suliman via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: > Docs says that: > "The total size of a static array cannot exceed 16Mb." > But when I am creation array of: > int [1000_000] x; // 1000_000 is equal ~ 0,95MB > app crush on start. > > Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager. First of all it is 4bytes * 1000_000 = 4000_000 bytes = 4kbyte, and it should not crash, are you sure this is the reason why app crash? |
February 09, 2017 Re: Static array size? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote:
> Docs says that:
> "The total size of a static array cannot exceed 16Mb."
> But when I am creation array of:
> int [1000_000] x; // 1000_000 is equal ~ 0,95MB
> app crush on start.
>
> Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager.
multiply by 4
|
February 09, 2017 Re: Static array size? | ||||
---|---|---|---|---|
| ||||
Posted in reply to jkpl | On Thursday, 9 February 2017 at 12:16:26 UTC, jkpl wrote:
> On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote:
>> Docs says that:
>> "The total size of a static array cannot exceed 16Mb."
>> But when I am creation array of:
>> int [1000_000] x; // 1000_000 is equal ~ 0,95MB
>> app crush on start.
>>
>> Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager.
>
> multiply by 4
Also static array is not on the heap so take care to which column of the task manager you monitor.
|
February 09, 2017 Re: Static array size? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozák | On Thursday, 9 February 2017 at 12:13:36 UTC, Daniel Kozák wrote:
> V Thu, 09 Feb 2017 11:22:28 +0000
> Suliman via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
> napsáno:
>
>> Docs says that:
>> "The total size of a static array cannot exceed 16Mb."
>> But when I am creation array of:
>> int [1000_000] x; // 1000_000 is equal ~ 0,95MB
>> app crush on start.
>>
>> Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager.
>
> First of all it is 4bytes * 1000_000 = 4000_000 bytes = 4kbyte, and it should not crash, are you sure this is the reason why app crash?
s/kbyte/megabyte
|
February 09, 2017 Re: Static array size? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote: > Docs says that: > "The total size of a static array cannot exceed 16Mb." > But when I am creation array of: > int [1000_000] x; // 1000_000 is equal ~ 0,95MB > app crush on start. > > Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager. First of all, as others said it is 4 bytes * 1000000, what gives about 4MB. Do you allocate this array on the stack? (local variables are created on the stack) If yes, maybe you've exceeded the size of the stack. Declare the array out of the scope of any function and check again. The size of the stack can be set in the linker (http://forum.dlang.org/post/mailman.766.1291253609.21107.digitalmars-d@puremagic.com). |
Copyright © 1999-2021 by the D Language Foundation