SFML community forums
Help => General => Topic started by: JeZ-l-Lee on February 13, 2009, 06:02:20 pm
-
App.Close();//Does it free memory used by resources?
Just want to be clear as to what "App.Close();" does.
Thanks....
-
If you mean Images, Soundstreams and Fonts with resources, then no. They are handled independently from the window.
sf::Window::Close() just closes the window itsself - it won't appear any more on the screen. After invoking the member function Create(), you can use it again.
-
kinda similar to the above question, but if I have a class that stores Images and such, and I close the program (close the exe) is the memory freed? I guess this is a basic C++ question, but just want to know if I don't explicitly use delete on pointers, does the program delete the data it's using (or like does the OS know that the memory used by the now dead program is available)
-
kinda similar to the above question, but if I have a class that stores Images and such, and I close the program (close the exe) is the memory freed? I guess this is a basic C++ question, but just want to know if I don't explicitly use delete on pointers, does the program delete the data it's using (or like does the OS know that the memory used by the now dead program is available)
To cleanly shutdown an app, you should delete all dynamically allocated memory before closing. If you don't, the OS will *probably* reclaim the memory anyway, but there's no guarantee and it's considered an ungraceful exit.
-
@ Astrof
That depends on the storage class of your variables. Do you request the free store (sometimes called "heap") - i.e. new? Memory you allocate with new has to be deallocated with delete.
If you just have variables on the stack (automatic storage class), they are released by leaving the scope. The memory of variables declared static or global (static storage class) are freed at the end of the program.
-
hmm ok, thanks, I guess I'll have to be careful in my code then.