We use the heap to store / allocate data of unknown size at compile time.
When storing data on heap we first request a certain amount of space. The operating system finds an empty spot in the heap that suffices and marks it as in use, returns a pointer to that location’s address. This is known as allocating to the heap.
It is slower than storing on the stack. The operating system has to find a big enough space to hold data, perform bookkeeping for next alloc.