Closed szmarczak closed 4 years ago
The native Node.js works as expected, no memory leaks whatsoever:
const {Resolver} = require('dns').promises;
const resolver = new Resolver();
resolver.setServers([
'127.0.0.1'
]);
const withTtl = {ttl: true};
let pending = 0;
const resolve4 = async hostname => {
pending++;
const result = await resolver.resolve4(hostname, withTtl);
pending--;
return result;
};
setInterval(() => {
resolve4(`${Math.random().toString().substr(2)}.test`);
}, 1);
setInterval(() => {
console.log(pending);
}, 1000);
For instance this has no memory leak: https://github.com/szmarczak/cacheable-lookup/compare/no-memory-leak?expand=1
Weird. As soon as I enable dns.lookup(...)
the memory leak appears...
Fixed.
Fixed.
what fixed it?
@molly-hayes ae7c02ff7dae76e06cce607a02ad98b5afc60691
Install
dnsmasq
Add
address=/.test/127.0.0.1
to/etc/dnsmasq.conf
sudo /usr/bin/dnsmasq
(start the server)Run (
cacheable-lookup@5.0.2
):The memory usage slowly increases every minute. It takes about 10-15 minutes to crash. To cause an instant crash, replace
setInterval
withwhile (true)
.