That's a large buffer. You are probably running out of stack space. Allocate to the heap by adding some memory management or using vector. You said you can use about 1000000. The variability there is due to the stack space being used by the rest of the code.
#include <vector>;
std::vector<char> buffer(1000000, '\0');
blob->read(&buffer[0], buffer.size());
For more information on stack vs heap memory, look here, and here