Your int *ptr is just a variable that stores the address, nothing more.
After the first int * ptr = new int; it contains the address of the dynamically allocated integer. After the second int * ptr = new int; it contains the address of another dynamically allocated integer.
What happens is then nothing special, the only thing you did not call delete , so the memory allocated for the first integer will never be freed. There is nothing to track, its address is not stored anywhere, and therefore it will remain useless allocated space until the program ends.
source share