Skip to content

Commit db5ebff

Browse files
committed
fixup! src: fix timing of snapshot serialize callback
1 parent 454caf1 commit db5ebff

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Flags: --expose-internals --zero-fill-buffers
2+
// Verifies that Buffer.allocUnsafe() allocates initialized memory under --zero-fill-buffers by
3+
// checking the usage count of the relevant native allocator code path.
4+
'use strict';
5+
6+
const common = require('../common');
7+
if (!common.isDebug) {
8+
common.skip('Only works in debug mode');
9+
}
10+
const { internalBinding } = require('internal/test/binding');
11+
const { getGenericUsageCount } = internalBinding('debug');
12+
const assert = require('assert');
13+
14+
const initialCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
15+
Buffer.allocUnsafe(Buffer.poolSize + 1);
16+
const newCount = getGenericUsageCount('NodeArrayBufferAllocator.Allocate.ZeroFilled');
17+
assert.notStrictEqual(newCount, initialCount);

0 commit comments

Comments
 (0)