PIE - Constant Memory Addressable Variables

Not sure if this is a bug or this is the expected action (If not a bug, it goes against the C++ standard), but any variable that has a constant memory address in the program will have the same value that was left at the end of the previous play.

I’m guessing memory is not sanitized during cleanup, and when the binary is loaded up again, the same addresses contain the same values.

This holds true for any variable with the static keyword, as well as anything global, or C style extern variables.

FYI - This was brought up before here.

Hi nathansizemore,

This actually isn’t a bug. The reason you are seeing static variables persist between PIE sessions, and I believe the same applies to global and C-style extern variables as well, is because the PIE session occurs within the Editor’s process. Since PIE does not create a separate process to run within, the variable is created within the Editor’s process, and persists throughout that process until the Editor is closed.

On the other hand, playing in Standalone does create a new process each time it runs, so the static variable would be created each time Standalone is started, and destroyed when it ends.