標準ライブラリ文字列のプレースメントnewのメモリリークに直面しています。標準ライブラリ文字列のプレースメント新しいメモリリーク
以下は、リークが表示されているコードを示しています。
string string1("new string");
char _string[sizeof(string)];
new(_string) string(string1);
リークがdbxを使用して発見され、それが
Actual leaks report (actual leaks: 1 total size: 52 bytes)
Total Num of Leaked Allocation call stack
Size Blocks Block
Address
========== ====== =========== =======================================
52 1 0x43f68 operator new < std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep < std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string < main
Possible leaks report (possible leaks: 0 total size: 0 bytes)
これは実メモリリークですか漏れとしてこれをintrepreting dbxのある以下のように示されていますか?
'_string'の' std :: string'デストラクタをどこかで呼び出していますか? – Sven
*達成しようとしていること* *つまり、なぜ新しいプレースメントを使用しますか?この壊れたソリューションを使用して解決しようとしている最初の問題は何ですか(実際のメモリ管理を持たない環境でコードを実行しない限り、プレースメントnewは解消されます)。 – Griwes
'_string'配列が' std :: string'に対して適切に整列されているとは限りません。 – GManNickG