If structures places data to stack why we do not getting stackoverflow on array of structures?

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 16 00:14:43 PDT 2017


On Wednesday, 16 August 2017 at 07:09:02 UTC, rikki cattermole 
wrote:
> On 16/08/2017 8:06 AM, Suliman wrote:
>> If structures placing data on the stack why we do not getting 
>> stackoveflow while we creating array of structures? Or for 
>> example big structure.
>> 
>> Am I right understand that structures placing data _only_ on 
>> stack? But the stack size is very limited (on Widnows it's 
>> just 1MB).
>> 
>> So how it's work?
>
> Struct's by themselves go on the stack.
> If they are allocated via new/malloc its on the heap (and hence 
> are pointers).
> Same situation with arrays or inside a class.

But for example if I am getting array of structs and getting data 
to it, where it's locating?


More information about the Digitalmars-d-learn mailing list