javascript - Client stores all images in data stream permanently -


I am implementing a node server which periodically takes pictures from a webcam and through the node module Sends them to the customer.

However, by seeing the resources used by my browser (in Chrome development tools) it seems that every image is being stored indefinitely by the client (or possibly by the server).

The code used by me is the delivery. Example in JS readmeem is similar to "pushing client":

server code

  // Set the camera to take a snapshot and Send it to the required framerate set interval (function ()). // Take a snapshot of the current view cam.snapshot ('./ current_view.jpg', function (Jpeg) {// this snapshot to client delivery. Send ({name: 'current_view.jpg', path: './current_view .jpg '})}}) Delivery. N ('send.success', function (file) {//console.log ('The file has been successfully sent to the client');}); }, Camera update date);  

customer code

  var distribution = new distribution (socket); Delivery.on ('receive.start', function (fileUID) {//console.log ('Getting a file!');}); Delivery.on ('receive.success', function) {if (file.isImage ()) // // new file to source of IIG tag $ (' img ') ARRR (' src ',' File.dataURL ( ); Console.log (file);};});  

Is it impossible to delete each file when the next file is received?

I just take a quick look at the client side source and add it to every received image object It also has the UUID key of the image, if you want to cap the memory leak, then it means to remove the image after the image is received. Its 140 objects are being added to the object:

  _this.receiving [file.uid] = filePackage;  

On top of this, if you modify 'get.success', see:

  pubSub.subscribe (' get.success ', Function (filePackage) {_this.socket.emit (' send.success', filePackage.uid); Delete _this.receiving [filePackage.uid];});  

This memory leak should be corrected However, you may have to do some testing to confirm that it does not break anything ...


Comments