ある Release exe をテストしていると
—————————
D_MIT
—————————
メモリが不足しています。
—————————
OK
—————————

この exe は,それほどメモリを使用しないもの.タスクマネージャーで確認してもピークで 50 M 程度.
また,何もなかったの様に exe が終了することもあり.
この時は,イベントビューアに 例外コード: 0xc0000409 が残っている.
原因は,次の様に文字列の配列(std::vector<tstring> ListFolds)からの取得で,インデックスが正しくなかったため.
long sel = -1 ;
// …
tstring sel_fold = ListFolds[sel] ;
デバッグ版 exe は vector subscript out of range となる.
—————————
Microsoft Visual C++ Runtime Library
—————————
Debug Assertion Failed!
Program: c:\Temp\TestMIT\d_mit\Debug.145\d_mit.exe
File: C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Tools\MSVC\14.50.35717\include\vector
Line: 1931
Expression: vector subscript out of range
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
—————————
中止(A) 再試行(R) 無視(I)
—————————
次の様にインデックスの範囲をチェックする必要がある.
tstring sel_fold ;
if (0<=sel && sel<long(ListFolds.size())) {
sel_fold = ListFolds[sel] ;
}
メモリ不足のエラーメッセージ!すぐできる応急処置と解決策
std::vectorの[ ]に引っかかった話
Windows10で「PCのメモリが不足しています」と警告が出る時は?