I would like to know whether a program crash or user forced quit will return the dynamic allocated memory to the computer. Or the memory will leak until system restart.
Most modern OSes will automatically reclaim all process memory after the process terminates. Usually, this works by having the OS evict all virtual pages associated with the process from its page table. Consequently, unless you have an old OS or hit a weird OS bug, the memory should be reclaimed.