Objects that get allocated on the heap can change their size at any time. A good example of an object that is allocated on the heap is a mutable array. This kind of array can be modified so elements can be added and removed. This means that your app can't allocate a fixed size of memory for this array, and it has to grow and shrink the allocated memory based on the required size.
Classes are also allocated like this; the compiler assumes that a class might have to resize its required memory at any time. One of the reasons for this is that classes aren't as strict about mutability as structs are. In our experiments earlier, you saw that you could change the name property of a class instance that was declared with let. Because this is possible, the size in memory for our instance could change whenever we assign a new name.
As the memory allocation for reference types is very dynamic, it's also a lot slower to create instances of reference types. The memory overhead is a lot bigger than the overhead caused by value types that are allocated on the stack. Let's take a look at this now.