You don't think bad_alloc is a memory issue? How big does N have to be to fail?