Question: will a global unique_ptr be released on exit? #21658
-
Hi, I am trying to figure how to properly clean a complex program on exit, that is built using c++. If anything is, let's say forgotten, in a regular program running in an OS, at exit time, all the memory is cleaned up. Now when a program is ran on Emscripten, and it exits, afaict "nothing" happens and a global variable will keep it's value at exit. I am trying to figure if using a global unique_ptr helps or if I would still need to explicitly clean it up and set it to a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use You shouldn't need to use any kind of smart pointer. Normal object destructors (or |
Beta Was this translation helpful? Give feedback.
You can use
-sEXIT_RUNTIME=1
if you want to get the normal exit behaviour where descructors run like they would on your native OS.You shouldn't need to use any kind of smart pointer. Normal object destructors (or
atexit
callbacks) should work fine.