Open
Description
When you run this simple code, memory grows unbounded. In my test it leaked more than 5 GB of memory.
import createKeccakHash from 'keccak'
const hash = msg => {
return '0x' + createKeccakHash('keccak256').update(msg).digest('hex')
}
const mine = function(seed, difficulty = 5) {
let nonce = 0;
difficulty = parseInt(difficulty);
const prefix = '0x' + new Array(difficulty).fill('0').join('')
while (true) {
const h = hash(seed + nonce);
if (!!h && h.substring(0, difficulty+2) === prefix) {
return nonce;
}
nonce += 1;
}
}
console.log("running ....")
const seed = "hfjshjdhsjhdjshdjs"
const nonce = mine(seed, 8)
console.log({
nonce,
})
the createKeccakHash
method thakes some memory and not release it.
Metadata
Assignees
Labels
No labels