Advertisement Jump to content
Sign in to follow this  
Tree Penguin

bad_alloc when memory is far from full

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

Hi, i get this exception when allocating memory with new (even when i only ask for one byte) and it should mean there's not enaugh memory available. Right now, my application uses only 26 MB and the total memory usage is about 380 of 1024MB so that's obviously not the case. Are there any stupid mistakes that can cause this exception? I don't think posting code is an option, it's either posting the preceding lines (about 2000 of them) or just char *a=new char[1];, there must be some common causes. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
You can get a std::bad_alloc() if your heap has been corrupted. Usual causes are buffer overruns, but you can also get it from using a pointer to an object that has already been deleted, possibly from calling delete [] when you wanted delete or vice versa, calling delete [] on a pointer to a base class when the array is of a derived class type, calling delete on a base pointer with no virtual destructor and so on.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!