0

Ok, I'm scratching my head here. I am playing with the node-serialport library and when I run this script, the memory is eaten up at a rate of 2MB per second:

var SerialPort = require('serialport');
var port = new SerialPort('/dev/ttyAMA0', {
  baudRate: 115200
});


// Switches the port into "flowing mode"
port.on('data', function (data) {
  console.log('Data:', data.toString() );
});

I don't even have anything connected to the serial port and it just starts eating ram. The weird thing is that I don't have this problem on a raspberry pi zero (without the wifi). The node versions are the same, the node-serialport versions are the same, they are both on the same version of Raspbian. I'm at a loss as to where to go next.

Details:

root@raspberrypi:# node -v
v6.11.4 
root@raspberrypi:# grep serialport package.json 
    "serialport": "^6.2.0",
root@raspberrypi:~# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.3 (stretch)
Release:    9.3
Codename:   stretch
root@raspberrypi:~# cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=74121984-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash

I thought it might be this issue but after upgrading to 6.2.0 the issue still persists and now I'm out of ideas. :(

1
  • memory is eaten up at a rate of 2MB per second ... change the baud rate .... see if the 2MB per second changes
    – jsotola
    Commented Jun 25, 2018 at 2:22

2 Answers 2

2

Find another library. node-serialport seems to leak memory like a sieve!

You may wish to have a look at this library instead.

0

As it turns out, the bluetooth uses the same serial port, so they were likely fighting.

From the github issue I opened:

If Bluetooth is not needed, add dtoverlay=pi3-disable-bt to /boot/config.txt and reboot. Now full UART /dev/ttyAMA0 is usable on GPIO14 and 15.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.