Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak #339

Open
Arkdevnoder opened this issue Jan 30, 2020 · 0 comments
Open

Memory leak #339

Arkdevnoder opened this issue Jan 30, 2020 · 0 comments

Comments

@Arkdevnoder
Copy link

Arkdevnoder commented Jan 30, 2020

A memory leak was detected at > 2 RPS.
Here is the code for testing (I apologize for the design of the code, I added an excerpt for issuing an HTML dump):

const fs = require("fs"); 
const rp = require('request-promise'); 

async function vk_post(data){ 
var options = { 
method: 'POST', 
uri: "https://api.vk.com/method/messages.send?v=5.68", 
form: data, 
headers: { 
'User-Agent': 'E-Bot-handler' 
}, 
json: true 
}; 
try { 
const data = await rp(options); 
return data; 
} catch(e) { 
return e; 
} 
} 


let data = { 
message: "Hello", 
peer_id: "281618690", 
access_token: "1rtp142231432twg2" 
} 


setInterval(async function(){ 
await vk_post(data);
}); 
let x = 0; 


setInterval(function(){ 
console.log(process.memoryUsage()); 
x = x+10; 
load = process.memoryUsage().rss/100000; 
loadX = process.memoryUsage().heapTotal/100000; 
loadY = process.memoryUsage().heapUsed/100000; 
loadZ = process.memoryUsage().external/10000; 
fs.appendFileSync('/var/www/html/load2.html', '<div style="bottom: '+load+'px; left: '+x+'px; position: absolute; height: 10px; width: 10px; background: red;"></div>'+ 
'<div style="bottom: '+loadX+'px; left: '+x+'px; position: absolute; height: 10px; width: 10px; background: blue;"></div>'+ 
'<div style="bottom: '+loadY+'px; left: '+x+'px; position: absolute; height: 10px; width: 10px; background: green;"></div>'+ 
'<div style="bottom: '+loadZ+'px; left: '+x+'px; position: absolute; height: 10px; width: 10px; background: pink;"></div>' 
); 
}, 300);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant