Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: App.Close();//Does it free memory used by resources?  (Read 4350 times)

0 Members and 2 Guests are viewing this topic.

JeZ-l-Lee

  • Jr. Member
  • **
  • Posts: 80
    • ICQ Messenger - 223180991
    • MSN Messenger - JeZLee@Live.com
    • AOL Instant Messenger - SLNTHERO@aol.com
    • View Profile
    • http://www.SilentHeroProductions.com
    • Email
App.Close();//Does it free memory used by resources?
« 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....
JeZ+Lee
Silent Hero Productions(R)
Video Game Design Studio

http://www.SilentHeroProductions.com

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
App.Close();//Does it free memory used by resources?
« Reply #1 on: February 13, 2009, 06:21:23 pm »
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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
App.Close();//Does it free memory used by resources?
« Reply #2 on: February 13, 2009, 08:16:51 pm »
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)

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
App.Close();//Does it free memory used by resources?
« Reply #3 on: February 13, 2009, 09:10:53 pm »
Quote from: "Astrof"
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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
App.Close();//Does it free memory used by resources?
« Reply #4 on: February 13, 2009, 09:15:02 pm »
@ 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
App.Close();//Does it free memory used by resources?
« Reply #5 on: February 14, 2009, 12:11:12 am »
hmm ok, thanks, I guess I'll have to be careful in my code then.