L
L
lem_prod2016-03-17 13:03:51
Programming
lem_prod, 2016-03-17 13:03:51

Where is the dynamics of memory?

As far as I understand, when declaring a static array,
int arr[n]
arr is in fact a pointer, and in general this construction is equivalent
int* arr = new arr[n]
, that is, that there is something that can be done there through "*" and arr[n]
why, in the first case, they say that static allocation occurs memory, and in the second dynamic ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-03-17
@petermzg

In the first case, memory is allocated on the stack, i.e. it just changes the value of the ESP register.
The size of this memory is limited by the value specified during the initialization of the stream, by default 1 MB.
In the second, you get a pointer to dynamically allocated memory. In this case, you can allocate significantly more memory. The limitation is only on the bit depth of the system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question