Giter Club home page Giter Club logo

Comments (7)

benschumacher avatar benschumacher commented on July 17, 2024 1

This issue is ancient, but I fixed a memory leak related to connections closing in rtl_tcp in my fork: https://github.com/benschumacher/rtl-sdr/tree/rtltcp_memory_leak

This has been submitted as a PR to the upstream project: pinkavaj/rtl-sdr#5

from rtlamr.

bemasher avatar bemasher commented on July 17, 2024

Are you killing the rtl_tcp instance between executions of rtlamr as well?

from rtlamr.

tracyj avatar tracyj commented on July 17, 2024

No. I start rtl_tcp as a service at boot, and let it continue to run.

raspberrypi:/etc/init.d> more rtltcpd.sh
#!/bin/bash
# /etc/init.d/rtltcpd.sh

### BEGIN INIT INFO
# Provides:          rtl_tcp for automatic meter reading
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This service is used to manage rtl_tcp
### END INIT INFO


case "$1" in
    start)
        echo "Starting rtl_tcp"
        /usr/local/bin/rtl_tcp >/dev/null 2>&1
        ;;
    stop)
        echo "Stopping rtl_tcp"
        killall rtl_tcp
        ;;
    *)
        echo "Usage: /etc/init.d/rtltcpd.sh start|stop"
        exit 1
        ;;
esac

exit 0
raspberrypi:/etc/init.d>

from rtlamr.

bemasher avatar bemasher commented on July 17, 2024

Before I get too far into this could you tell me if the memory usage remains the same after killing rtl_tcp once free memory has gotten low from running rtlamr multiple times?

I suspect that rtl_tcp isn't cleaning up it's thread/linked-list appropriately when the worker thread exits, and this may be due to rtlamr not closing the connection politely. It's extremely unlikely that rtlamr itself has a memory leak since go is garbage collected, I have very little control over what stays in memory while it is running and I'm not doing anything unsafe that the garbage collector couldn't handle.

from rtlamr.

tracyj avatar tracyj commented on July 17, 2024

I have included a log of running rtlamr multiple times until the memory gets fairly low. I execute free after every run. At that point, I find the process for rtl_tcp, and kill it. I then execute free again, and it looks like all the memory has been returned.

memory_leak_kill_rtl_tcp.txt

from rtlamr.

bemasher avatar bemasher commented on July 17, 2024

I've confirmed that rtlamr is closing it's connection to rtl_tcp appropriately and the leak exists in rtl_tcp. I'll take a look at filing a bug report for rtl_tcp but for the time being I'm closing this issue.

In the meantime, you'll want to kill and restart rtl_tcp once every several rtlamr executions.

Another option would be to figure out which frequencies your meter operates on and set the center frequency appropriately as well as shortening the symbol length to 8. On most electric meters this will produce a reading once every 25 minutes and require minimal cpu resources.

from rtlamr.

tracyj avatar tracyj commented on July 17, 2024

Thank you for your dedication and hard work to this project.

from rtlamr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.