niklauslee / dht

Kaluma library for DHT humidity and temperature sensor
MIT License
2 stars 0 forks source link

Memory Leak in dht package #1

Open sergeychernov opened 2 years ago

sergeychernov commented 2 years ago

I've write a simple code for testing. As you can see below, i've called dht.read(); less then 2000 times and ran out of memory const {DHT} = require('dht'); const dht = new DHT(15, DHT.DHT21); let counter = 0; setInterval(() => { dht.read(); counter++; }, 1000); setInterval(() => { const memory = process.memoryUsage(); console.log(heapPeak:${memory.heapPeak>>10}k heapUsed:${memory.heapUsed>>10}k heapTotal:${memory.heapTotal>>10}k Amount:${counter},); }, 60*1000); // Done // > // > .load // heapPeak:24k heapUsed:23k heapTotal:195k Amount:60 // heapPeak:30k heapUsed:28k heapTotal:195k Amount:120 // heapPeak:36k heapUsed:32k heapTotal:195k Amount:180 // heapPeak:42k heapUsed:38k heapTotal:195k Amount:240 // heapPeak:48k heapUsed:48k heapTotal:195k Amount:300 // heapPeak:55k heapUsed:52k heapTotal:195k Amount:360 // heapPeak:61k heapUsed:58k heapTotal:195k Amount:420 // heapPeak:67k heapUsed:63k heapTotal:195k Amount:480 // heapPeak:73k heapUsed:70k heapTotal:195k Amount:540 // heapPeak:79k heapUsed:76k heapTotal:195k Amount:600 // heapPeak:85k heapUsed:81k heapTotal:195k Amount:660 // heapPeak:94k heapUsed:94k heapTotal:195k Amount:720 // heapPeak:97k heapUsed:93k heapTotal:195k Amount:780 // heapPeak:104k heapUsed:104k heapTotal:195k Amount:840 // heapPeak:113k heapUsed:113k heapTotal:195k Amount:900 // heapPeak:120k heapUsed:120k heapTotal:195k Amount:960 // heapPeak:126k heapUsed:126k heapTotal:195k Amount:1020 // heapPeak:131k heapUsed:131k heapTotal:195k Amount:1080 // heapPeak:136k heapUsed:136k heapTotal:195k Amount:1140 // heapPeak:140k heapUsed:140k heapTotal:195k Amount:1200 // heapPeak:152k heapUsed:137k heapTotal:195k Amount:1260 // heapPeak:157k heapUsed:157k heapTotal:195k Amount:1320 // heapPeak:165k heapUsed:152k heapTotal:195k Amount:1380 // heapPeak:170k heapUsed:170k heapTotal:195k Amount:1440 // heapPeak:177k heapUsed:163k heapTotal:195k Amount:1500 // heapPeak:181k heapUsed:181k heapTotal:195k Amount:1560 // heapPeak:189k heapUsed:172k heapTotal:195k Amount:1620 // heapPeak:191k heapUsed:187k heapTotal:195k Amount:1680 // heapPeak:191k heapUsed:178k heapTotal:195k Amount:1740 // heapPeak:191k heapUsed:184k heapTotal:195k Amount:1800 // heapPeak:191k heapUsed:190k heapTotal:195k Amount:1860 `

sergeychernov commented 2 years ago

If i call clean pulseRead(15, 100, { timeout: 25000, startState: LOW, mode: INPUT, trigger: { startState: HIGH, interval: [10000, 18000], }, }); inside setInterval situation is same. I think the leak is on the Kaluma Core.

communix commented 1 year ago

@sergeychernov I fixed this issue and push the code into the master branch. Please test it. The new FW is attached. kaluma-rp2-pico-1.0.0.uf2.zip