test: Memory leak reproduction for futures
This commit is contained in:
parent
1e8d20a559
commit
81498ecbea
3 changed files with 30 additions and 0 deletions
|
@ -5,3 +5,4 @@ await createSuite('tokio-future')
|
||||||
await createSuite('serde')
|
await createSuite('serde')
|
||||||
await createSuite('tsfn')
|
await createSuite('tsfn')
|
||||||
await createSuite('buffer')
|
await createSuite('buffer')
|
||||||
|
await createSuite('returns-future')
|
||||||
|
|
26
memory-testing/returns-future.mjs
Normal file
26
memory-testing/returns-future.mjs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { createRequire } from 'module'
|
||||||
|
|
||||||
|
import { displayMemoryUsageFromNode } from './util.mjs'
|
||||||
|
|
||||||
|
const initialMemoryUsage = process.memoryUsage()
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
|
||||||
|
const api = require(`./index.node`)
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
let i = 1
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
|
while (true) {
|
||||||
|
await api.returnsFuture()
|
||||||
|
if (i % 100000 === 0) {
|
||||||
|
displayMemoryUsageFromNode(initialMemoryUsage)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((e) => {
|
||||||
|
console.error(e)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
|
@ -171,3 +171,6 @@ pub fn buffer_pass_through(buffer: Buffer) -> Buffer {
|
||||||
pub fn array_buffer_pass_through(array_buffer: Uint8Array) -> Uint8Array {
|
pub fn array_buffer_pass_through(array_buffer: Uint8Array) -> Uint8Array {
|
||||||
array_buffer
|
array_buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[napi]
|
||||||
|
pub async fn returns_future() {}
|
||||||
|
|
Loading…
Reference in a new issue