Accommodation "Hello World!" in your code causes the compiler to include this line in the compiled executable. When the program is executed, this line is created in memory before the main call and, I believe, even before the assembly is called on __start (which starts with the start of the static initializers). The contents of char * x not allocated using new or malloc , or in the frame of the main stack, and therefore cannot be unallocated.
However, a char x[20] = "Hello World" declared inside a function or method is allocated on the stack, and while in scope there will actually be two copies of this "Hello World" in memory - one previously loaded with executable file, one to the buffer allocated to the stack.
source share