Title: google-perftools shows that st75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0string75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_Rep75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_S_create is using 20gb of memory
Tags: c++;memory
Question: I am profiling my program using Google Perf tools and find that I am running out of memory on st75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0string75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_Rep75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_S_create.  Perf tools shows 20gb in use:
20526.0  92.1%  92.1%  20526.0  92.1% st75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0string75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_Rep75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0_S_create
Does anyone know what this could be?  So far I've found:
Suggestions that the st75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0string allocator could be grabbing large chunks of memory to avoid calling new.
st75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0string 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.
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?
Comment: Maybe you have a lot of really big strings?

Comment: 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.

Comment: 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.

Comment: 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.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:11/24/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><memory>', 'Title': 'google-perftools shows that std::string::_Rep::_S_create is using 20gb of memory', 'ViewCount': 847, 'id': 33905579, 'user_AboutMe': '', 'user_AccountId': 30780.0, 'user_DisplayName': 'Eric Conner', 'user_Reputation': 10056.0, 'user_Views': 434.0, 'user_id': 84128.0}}