分配大小无效:4294967295 字节

Invalid allocation size: 4294967295 bytes

本文关键字:4294967295 字节 无效 分配      更新时间:2023-10-16

我正在尝试构建我的第一个C++应用程序,并且正在尝试浏览表格。但是,调试器会显示此错误消息。

DWORD *dwWatch = new DWORD[taille]; // <-- The error appears here.
for (LISTSTR::iterator i = listMe.begin(); i != listMe.end(); ++i, j++)
    {
        dwWatch[j] = m_DirWatcher.WatchDirectory(m_strDirectoryToMonitor, dwChangeFilter, pHandler, true, NULL, NULL);
    }

请问我该如何解决这个问题?

taille 的实际值是 -1,因为无符号 int 的 4294967295 和有符号 int 的 -1 都在内存中0xffffffff。

因此,请查看其值何时更改为 -1。请注意,某些标准函数在失败时返回 -1。