Memory Issue In Buffers
See original GitHub issueHello,
I have a large array that needs to be sent over a socket connection from a server (Node Js) to a Client (Holo Js / Hololens) every second or so. Sending it as a normal array is kind of slow so i resorted to converting the list to a buffer.
var buffer = new Float64Array(list).buffer
var data = {
buffer : buffer
}
client.emit('sendData', data);
However, I realized that the app would crash and start throwing an out of memory exception after a while. After looking into it more i realized that the memory displayed on the diagnostic tools view in visual studio keeps increasing every time a new buffer is being received. This does not happen when receiving a normal array.
I attached a sample node js server NodeJs - Socket Server.zip
And here is a small script to run on HoloJs to replicate the problem.
var url = "http://{ip}:{port}/";
var socket = io(url, { transports: ['websocket'] });
socket.on('connect', function () {
console.log('connected');
socket.emit('requestData');
});
socket.on('sendData', function (data) {
socket.emit('requestData');
});
Another thing i tried that caused the same behavior is this:
setInterval(function () {
var test = [];
for (var i = 0; i < 100000; i++) {
test.push(i);
}
var data = {
test: test
};
// console.log(data);
}, 100);
When i comment out the console.log no issues happen but adding it would cause the memory to keep increasing until eventually the app crashes due to an out of memory exception.
Regards, Omar.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
PS: Thank you for investigating and reporting this issue. Please let me know if you see memory leaks with the fixes above.
Thank you Cristi, its working great now and memory is stable. Please note that i get this error sometimes:
Exception thrown at 0x77442552 in ThreeJSApp-Vs2017.exe: Microsoft C++ exception: Js::RejitException at memory location 0x087FF117.
but it seems that it doesn’t affect anything and the script just keeps running normally.