On my current STL implementation (VS2010 SP1), str("") releases all memory
std::stringstream ss;
for(unsigned int i = 0; i<10000000; ++i)
{
ss << "QWERTYUIOPASDFGHJKLXCVBNM";
}
ss.str(""); // memory released here
Reference: "Internally, the function calls the str member of its internal string buffer object."
I interpret that sentence to mean that if I assign an empty string, it'll copy-construct the underlying buffer to that.