在MSVS c ++中,我使用以下命令启用内存泄漏检测:
import "regenerator-runtime/runtime";
import "core-js/stable";
import "fetch-mock"
const fetchMock = require('fetch-mock');
fetchMock.config.sendAsJson = true; \\I've tried with and without this part and I get the same error
import updateUI from './updateUI';
import { isIterable } from "core-js";
describe('updateUI', () => {
it('can fetch', async () => {
fetchMock.get('/sentiment', {polarity: 'polarity', polarity_confidence: 'polarity confidence', subjectivity: 'subjectivity', subjectivity_confidence: 'subjectivity confidence'});
const res = await updateUI('/sentiment');
const allData = await res.json();
expect(allData.polarity).toEqual('polarity');
expect(allData.polarity_confidence).toEqual('polarity confidence');
expect(allData.subjectivity).toEqual('subjectivity');
expect(allData.subjectivity_confidence).toEqual('subjectivity confidence');
})
})
如果我创建一个(自定义类的)对象,该对象是在堆栈上创建的,则输出如下:
#define _CRTDBG_MAP_ALLOC
这很有意义,因为分配一直保持到应用程序结束。这不是内存泄漏。
如果我对同一对象使用NEW和DELETE,则不会出现“内存泄漏”。
Detected memory leaks!
Dumping objects ->
{84} normal block at 0x00BBA448, 8 bytes long.
Data: <$| > 24 7C BB 00 00 00 00 00
我的问题是,我可以在应用程序结束之前取消分配在堆栈上创建的对象,以便内存泄漏检测不会显示它们吗?您无法删除它们。
谢谢。