Does the memory get unallocated when program exits?
When you run your program its memory allocations take the form of page allocation requests to the operating system.  When your program terminates, the operating system notices and returns all the allocated pages to the list of free pages, which can then be used by other processes.  It does not matter if your program leaks memory (other than potentially using more memory as a result), because ultimately the operating system will reclaim everything.