Memory management is always one of the most important things to get right in your computer program to ensure stability and good, bug-free operation of your code. A dangling pointer (pointer referring to something that has been removed from memory) is an example of a bug that is hard to track if it occurs.
In any computer program, memory management is extremely important. UE4's UObject reference-counting system is the default way that memory is managed for actors and classes derived from the UObject class. This is the default way that your memory will be managed within your UE4 program.
If you write custom C++ classes of your own, which do not derive from UObject, you may find the TSharedPtr / TWeakPtr reference-counted classes useful to use. These classes provide reference counting and automatic deletion for objects when they have no more references.
This chapter...