kwijibo28 wrote:
>
> Thanks for the reply guys.
> I've tried all this but it still doesn't work. So I'll be a little
> more specific about what I am trying do. I'm writing an MFC aplication
> using VC++ 6.0.
>
> When I write something like:
>
> try {
> foo.resize(power(2,32)-1);
> }
> catch (std::bad_alloc const&) {
> ::MessageBox(NULL,"Memory allocation fail!","Error",MB_OK);
> }
>
> I've got a message box that pop up with a "Out of memory" message when
> foo.resize is called. I don't know where this message box come from.
Deep from the internals of your runtime system.
MS has yet to learn that emitting such messages is just a way to
support lazy programmers. The number of programmers trying to get
rid of the floppy-disk-failed message in DOS is legion. MS has not
learned from that.
> And even worst, my message box with "Memory allocation fail!" don't
> appear.
VC++ 6.0 does not throw an exception when a memory allocation failes.
Instead NULL is returned from new. Don't know what resize does with
that information.
But honestly: 2 to the power of 32 is a lot of memory. If we assume
that foo holds unsigned characters, that would be 4 GB. Tracing your
post back, I see that foo holds floats, so that would sum up to
16 GB in VC++. That's a lot. Are you sure you need that much memory?
--
Karl Heinz Buchegger