str.clear();
or
str = "";
However, as stated in the comments, this does not guarantee (and, in fact, is unlikely) to actually return the heap memory. Also, work is not guaranteed, but in practice, the swap trick works quite well:
std::string().swap(str);
However, implementations that use a little string optimization will save several bytes of stack space (and str itself, of course, also lives on the stack).
In the end, I agree with all the comments saying that it is doubtful why you want to do this. Ass in the near future, when str goes out of scope, its data will be automatically deleted:
{ std::string str;
source share