0

I am profiling my program using Google Perf tools and find that I am running out of memory on std::string::_Rep::_S_create. Perf tools shows 20gb in use:

20526.0  92.1%  92.1%  20526.0  92.1% std::string::_Rep::_S_create

Does anyone know what this could be? So far I've found:

  1. Suggestions that the std::string allocator could be grabbing large chunks of memory to avoid calling new.
  2. std::string destructor does not get called due to exit() or some such call. So far I have not found any evidence of this in my program.

Any other ideas about how I could track this down?

Thanks.


Edit:

Via this answer I moved libstdc++ to shared and enabled GLIBCXX_FORCE_NEW and that seems to have fixed the problem. It's still unclear to me why the issue occurred in the first place though. Anyone have an idea?

Community
  • 1
  • 1
Eric Conner
  • 10,422
  • 6
  • 51
  • 67
  • Maybe you have a lot of really big strings? – user253751 Nov 24 '15 at 23:14
  • This looks like the output of the [`tcmalloc` heap-profiler](https://gperftools.googlecode.com/svn/trunk/doc/heapprofile.html) read by `pprof --text`. If so, `pprof --gv` will give you the call-graph view. Combine that with the periodic heap allocation dumps to figure out when and where this happened. – Pradhan Nov 25 '15 at 00:05
  • This is on a remote linux box. Can I somehow view the graphical display? When I try it complains that it can't open the graphical display. – Eric Conner Nov 25 '15 at 00:34
  • 1
    You can dump the call-graph to a format of your choice : `pprof --pdf`, for example, writes the `pdf` output to `stdio`. Look at `pprof --help` for more file formats. – Pradhan Nov 25 '15 at 16:32

0 Answers0