Jump to content
  • Advertisement
Sign in to follow this  
SpacedOut

C++ question

This topic is 4794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if you use 'new' to allocate objects but don't delete them at the end of the program, what will happen? will Windows XP or other OS's clean up the mess, or will the data stay there until you shutdown?

Share this post


Link to post
Share on other sites
Advertisement
I really dont know cuz I never didnt de-allocate used memory. Unless you loaded a huge 3d world, dont worry if you accidentally missed a variable or so... lol.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Very bad things:) Actually I think WinXP is pretty good at cleaning up your mess after a program ends, however older OS aren't so nice (not sure on this though).

It's always a good idea to delete anything you create though no matter what.

Share this post


Link to post
Share on other sites
OS will free up all memory allocated memory by the application - under normal circumstances...
However i cannot stress it enough how bad practice is not to release memory, it leads to the dreaded "Memory leak".
Release every resource you allocate (memory, handles, etc) when you are done with them.

Share this post


Link to post
Share on other sites
any modern O.S. wll clean up after you, but it one of the worst programming practises you could have.

if your program is going to run for more than 5 minutes, not deallocating memory will begin to become noticable. particularly in things like dedicated servers, what server admin would like having to restart the program every so often just because you forget delete.

we all make mistakes, but i try be as careful as i can about memory leaks, as they (usually) visibly affect my programs.

think about using a smart pointer or auto pointer ( or whatever its called ) from boost.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
failing to delete allocated memory is sloppy and if you are loading a lot of stuff into memory or that function gets called several thousand times, your program (or others), will start to notice.

Share this post


Link to post
Share on other sites
You have undefined results. If your type has a non-trivial destructor, it most-likely will never get called. Your OS will probably release all of the memory associated with your program when it is terminated, but that should be least of your worries.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!