Getting bad_alloc Exception from SFML

So I'm trying to render an entire map from one of my games onto a single image and save it to a file. To do this the image needs to be 14,400 by 14,400 pixels (ridiculous I know). When I try to create an sf::Image of that size it throws an exception. This seems normal enough, except that GIMP can easily create an image of that same size. Is there any particular reason that GIMP can get the memory and I cannot? By my calculations this is only around 830 MB of memory, and my system has 8 GB installed and several GB's free when I run the program. I know that sf::Image internally uses a vector<Uint8> to store the pixel data (32 bpp), however the 830 million elements needed is still way shy of the amount returned by vector.max_size() on my system. I'm honestly at a loss right now, this should be perfectly possible to do. Any help or insight is appreciated.
Ooh ooh this is a shot in the dark but are you compiling 32-bit or 64-bit? The ~2 GB limit for 32-bit might be causing problems? (Can't allocate a contiguous 830 MB out of the <2-3 GB that's possibly free).

Again, no idea if that's the issue but figure that might help.

Edit: Since sf::Image does just seem to be an std::vector, what happens when you just try to allocate the same amount of data to a "raw" vector?

Edit2: Found this http://en.sfml-dev.org/forums/index.php?topic=14529.0 64-bit seemed to be the problem for them (seems to describe your situation perfectly?)
Last edited on
Good call! I'll grab a 64 bit compiler and give it a shot. Thanks!
Woooo!! 64 bit was the solution! Thank you!
Topic archived. No new replies allowed.