I am using an ostringstream
object in an application that runs for a long time to print debug information to standard out. I toggle whether the application actually prints and clears the ostringstream
object based on a command line arg (e.g., verbose flag). When the verbose switch is not asserted I still write to the ostringstream
object but I never clear it.
I am trying to figure out how bad this is and whether I should take more care on clearing the object? Are there any negative repercussions such as using too much memory?
// example code
ostringstream oss;
while (1){
oss << " still alive " << endl;
if (verbose) { cout << oss.str(); oss.str("") }
}