Jump to content
  • Advertisement
Sign in to follow this  
ajm113

Safe Mode and Memory Leaks with std::string

This topic is 3040 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

I have a few questions about the std::string class and Safe Mode compiled software using pure C++.

Ok well, we all know this string class returns the memory when ever our engineered children shut down, but is it a good idea too use the clear function when ever possible still?

Even when we are dealing with software that's going too be left running? I'm currently developing a server and when I do a sync it leaves 33,000+ memory hanging there. Before it does anything it leaves 3,000+.

I'm guesting it's the large strings just chilling there.

Also whats up with Safe Mode applications? What's different about then the normally developed application for Windows? Do they make different windows calls? I was thinking on making a Safe Mode compiled executable, but I want too learn more about the differences and how they are made.


Thank you, Andrew.

P.S sorry about my grammar I'm listening too music while I work.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ajm113
I have a few questions about the std::string class and Safe Mode compiled software using pure C++.

Ok well, we all know this string class returns the memory when ever our engineered children shut down, but is it a good idea too use the clear function when ever possible still?

Nope. Just keep your string instances in as local a scope as possible and the memory will be reclaimed when they go out of scope. As for the string objects themselves, that's a different ballgame.

Quote:
Original post by ajm113
Even when we are dealing with software that's going too be left running? I'm currently developing a server and when I do a sync it leaves 33,000+ memory hanging there. Before it does anything it leaves 3,000+.

Err, what is "33,000+ memory"? 33MB? meh, most machines have several gig of memory, servers usually more. 33kb? I'm slightly more concerned about the possibility of a shard of satellite falling from the sky and impaling my little toe than I would be about 33kb.

If your memory really is an issue, you've got one of two problems:
1: you have a memory leak. Find it, and fix it.
2: your application is using too much memory full stop. This one is much trickier. Generally, adding more features will consume more memory. You will either need to optimise your existing memory usage or remove something that uses lots of memory (i.e. if you're building an index for a fast search that only happens rarely, maybe you'd be better without the index and just take the hit on the search)

Quote:
Original post by ajm113
Also whats up with Safe Mode applications? What's different about then the normally developed application for Windows? Do they make different windows calls? I was thinking on making a Safe Mode compiled executable, but I want too learn more about the differences and how they are made.


What do you mean by Safe Mode? Can you give an example? Something like Firefox's safe mode usually starts the application with all plug-ins disabled.

Share this post


Link to post
Share on other sites
Yeah, your right, maybe I should be more scared of Fire Fox then my server, compared too it's memory it's using a lot more then my server.

Well I sometimes see games or software saying something like (Safe Mode) in the exe's name. Like Fire Fox, but I wondered what most of those executables actually take away from the user. Such as window transparency effects, some assets such as "plug-ins".

Share this post


Link to post
Share on other sites
Quote:
Original post by ajm113
Well I sometimes see games or software saying something like (Safe Mode) in the exe's name. Like Fire Fox, but I wondered what most of those executables actually take away from the user. Such as window transparency effects, some assets such as "plug-ins".
Generally the idea is to disable all the optional extras (i.e. plugins, themes, extensions, scripts...) that might prevent the application from running if they are broken. This gives the user a chance to uninstall the broken elements.

Share this post


Link to post
Share on other sites
Quote:

Even when we are dealing with software that's going too be left running? I'm currently developing a server and when I do a sync it leaves 33,000+ memory hanging there. Before it does anything it leaves 3,000+.

How are you measuring usage? Task manager?
Taskman isn't a good source of memory usage information. It's showing your program's "active set" size. The active set isn't instantly reclaimed when you "delete" it, as the OS keeps a bit around incase you allocate something else. Also, things like memory fragmentation can cause a very large active set for a fairly small actual usage from your program.

Quote:

Also whats up with Safe Mode applications? What's different about then the normally developed application for Windows? Do they make different windows calls? I was thinking on making a Safe Mode compiled executable, but I want too learn more about the differences and how they are made.

As already stated, the idea is to disable anything you know has a chance to cause a problem. For games, there are often strange bugs that crop up due to hardware and drivers issues. The "safe" mode will usually turn off the advanced shaders, extentions, and overall reduce the quality of the game in exchange for making it more stable on a wider selection of platforms. Other software, as mentioned, will disable anything that the developers don't have direct control over. This means turning off plugins, skins, and scripts. The software might also turn off more intensive features, fancy window effects, stuff that normally runs in the background, and auto-updaters. In the end you have a program that is the bare minimum set of features that you need to modify the functionality of the program. So, if some game is crashing because you turned up the shadows to "ultra", then safe mode will reset all the graphics settings to "low" or "off". You can then go in and try setting them higher again till you find the cause of the crash/hang on your machine.

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!