bad_alloc exception even though memory available

Hi,
I have code (C++ under Windows 7 using VS2010) that creates many objects on the heap, each with a STL map<string, double> in it, and then inserts about 100 items into each map - overall, many thousands of such objects. I get a bad_alloc exception when running my code.
So far all good and well - except that the Windows Task Manager reports I have more than 3GB of available memory, not including virtual memory. Why doesn't my application get all the available resources in the system? 3GB seems more than just reserves. I don't think I have any data structure that requires contiguous memory (like STL vector<> - I use list<> to hold pointers to my objects).
Does anyone have any insight into this behavior? Any suggestions?
Thanks,
Yariv.
1) How many objects do you create? What is size of each element?
2) Do you have 3GB total or free at th moment you get bad_alloc?
3) Do you have 64 bit or 32 bit PC?
4) Do you compile for 32bit without LARGE_ADDRESS_AWARE?
Answers:
1) I create about 50,000 objects, each having a map containing about 60 key-value pairs (string to double typically).
2) 3GB free of 8GB total when the exception is raised.
3) 64 bit.
4) don't know, I'll check!
Can you post the code?

It shouldn't do that unless you have really large strings, MSVS does really strange thing in debug mode or your objects is really huge.
bad_alloc doesn't necessarily mean running out of memory.
More likely it's cause by another bug like writing out of bounds
Thanks for the advice. It seems that the LARGE_ADDRESS_AWARE solved the issue.
Sorry I can't post the code, it's way too messy and all over the place for me to be able to tease out the important parts in a reasonable amount of time.
Topic archived. No new replies allowed.