S
Soumen
Recently, I did a heap-profiling using google-perftool. And I'm
surprised to see string created through basic_string::substr() is
consuming around 10% of memory of entire program (67 GB). While
basic_string is used throughout the program, I don't see contribution
from any other path.
And this leads me thinking if basic_string::substr() has any extra
memory overhead for following type of usage:
1.
std::string subString;
// some code to find 'pos' from 'origString', where 'origString' is my
large string
subString = origString.substr(pos);
2. If 1 has indeed some memory overhead, will following help?
std::string subString(origString);
// some code to find 'pos' from 'subString'.
subString.erase(pos + 1);
I'm using gcc-4.2.2 on RHEL4.
Regards,
~ Soumen
surprised to see string created through basic_string::substr() is
consuming around 10% of memory of entire program (67 GB). While
basic_string is used throughout the program, I don't see contribution
from any other path.
And this leads me thinking if basic_string::substr() has any extra
memory overhead for following type of usage:
1.
std::string subString;
// some code to find 'pos' from 'origString', where 'origString' is my
large string
subString = origString.substr(pos);
2. If 1 has indeed some memory overhead, will following help?
std::string subString(origString);
// some code to find 'pos' from 'subString'.
subString.erase(pos + 1);
I'm using gcc-4.2.2 on RHEL4.
Regards,
~ Soumen