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 on Raspberrypi Zero W #1583

Closed
tiny-tinker opened this issue Jun 25, 2018 · 3 comments
Closed

Memory leak on Raspberrypi Zero W #1583

tiny-tinker opened this issue Jun 25, 2018 · 3 comments

Comments

@tiny-tinker
Copy link

  • SerialPort Version: 6.2.0

  • NodeJS Version: v6.11.4 also v8.11.1

  • Operating System and Hardware Platform: Raspbian GNU/Linux 9.3 (stretch)

  • Have you checked the right version of the api docs?: Yes

  • Are you having trouble installing and you checked the Installation Special Cases docs? No issues installing

  • Are you using Electron and have you checked the Electron Docs?: N/A

Summary of Problem

I am getting a memory leak of about 2MB per second and CPU thrashing.

Steps and Code to Reproduce the Issue

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 thought it might be #1572 so I waited for the fix there, but I still have the issue using 6.2.0 . The weird thing is that I don't have the memory leak on a raspberry pi zero (no wifi). Other assorted 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'm guessing it is environment related, but not sure where to look.

@shodan8192
Copy link

Confirmed on :

RPi Zero W v1.1
NodeJS : v8.11.3
Raspbian 9.4 (stretch)

rss usage grow by ~2MB/s and cpu load is almost 100%

Cause

On RPi Zero W (and probably RPi 3) port serial1 is linked to ttyAMA0 and used by Bluetooth

pi@zero:~ $ ls -la /dev/ttyAMA0
lrwxrwxrwx 1 root root 7 Jun 25 13:53 /dev/serial1 -> ttyAMA0
pi@zero:~ $ systemctl status hciuart.service -l
● hciuart.service - Configure Bluetooth Modems connected by UART
   Loaded: loaded (/lib/systemd/system/hciuart.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-06-25 13:53:17 CEST; 17s ago
  Process: 227 ExecStart=/usr/bin/btuart (code=exited, status=0/SUCCESS)
 Main PID: 357 (hciattach)
   CGroup: /system.slice/hciuart.service
           └─357 /usr/bin/hciattach /dev/serial1 bcm43xx 3000000 flow - b8:27:eb:35:a6:a0

Solution 1

Don't use /dev/serial1 or /dev/ttyAMA0.
Instead, add enable_uart=1 to /boot/config.txt and reboot.

Device /dev/serial0 will appear. It is wired to GPIO14 and 15.
This serial port is miniUART and have serious limitations (as one can find in net)

Solution 2 (maybe better)

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.

@xMTinkerer
Copy link

Woo! This did it:

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.

Thanks!

@reconbot
Copy link
Member

Nice!

@lock lock bot locked as resolved and limited conversation to collaborators Feb 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants