Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > bad_alloc in these situations?

Reply
Thread Tools

bad_alloc in these situations?

 
 
George2 George2 is offline
Senior Member
Join Date: Feb 2008
Posts: 108
 
      02-28-2008
Hello everyone,


In these situations, whether bad_alloc will be thrown?

1. Memory is reserved, even if not used. No "enough" memory to new operator (which reflects not enough memory for VirtualAlloc, even if not used (committed), but reserved);

2. The heap's internal data structures could be corrupted such that it cannot find the next free block (no pointer to the next free block), which would make it think it is out of memory.

3. The heap's internal data structures could be corrupted so that it points to random memory location, which could cause a crash, or try to give you memory that was still in use.

My option, (1) and (2) will throw bad_alloc, for (3) structured exception (access violation) will be thrown?


thanks in advance,
George
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
std::bad_alloc Gary Wessle C++ 5 08-15-2006 10:03 PM
new - bad_alloc or NULL Dennis George C++ 4 03-21-2006 05:48 PM
Catch bad_alloc? kk_oop@yahoo.com C++ 4 02-11-2006 09:31 AM
bad_alloc unhandled exception vulcan.wayne@gmail.com C++ 3 07-13-2005 05:12 AM
new not throwing bad_alloc Jacek Dziedzic C++ 3 07-30-2003 04:54 AM



Advertisments