std::string operator+() memory leak?

前端 未结 3 2007
南笙
南笙 2021-02-13 16:03

I\'m quite worry because I wrote a little application and it seems that there is a memory leak if I believe valgrind (What I actually do):

==9321== 251 bytes in          


        
3条回答
  •  故里飘歌
    2021-02-13 16:38

    I suspect what's happening is the compiler is using NRVO to put your temporary string into its real return location. That return string is then stored inside an object that's allocated and leaked off the heap.

提交回复
热议问题