P
P
Pantene7422017-02-17 19:35:52
Atmel AVR
Pantene742, 2017-02-17 19:35:52

How is memory allocated in C++?

The addresses of the memory cells allocated for the elements of the array go in order. but what if all the memory (assume such a situation) is filled through the cell (under the word cell is 8 bits). and I want to create an array for which there will be no heap space. then the array will fill the free cells? and accordingly the addresses
will no longer go in order.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2017-02-17
@Pantene742

This is called memory fragmentation. Some scavengers (like in Java or C#) are able to move objects and get a large continuous segment.
The C++ memory manager is not capable of defragmenting memory and will report out of memory .
In any case, an array - either in Java or C++ - will occupy a continuous piece of memory.
To combine junk languages ​​with system interfaces, there are ways to mark a struct as non-relocatable. But this is already at the junction of the Java/C# virtual machine and the system code, which is written in C(++).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question