revid-cli: memory leak in MTS mode

Issue #184 resolved
Alan Noble created an issue

This happens on master but was first observed as of commit 6dccc5c4d5074e7a8093e378566a098b70ff2b2f. It may well predate that commit though.

Note 59.5% memory usage was reached after just a few hours of running:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2222 pi 20 0 862408 224912 4236 S 3.9 59.5 5:35.66 revid-cli

This speaks to the need for a performance test to detect such regression, a separate issue.

Comments (20)

  1. Saxon Milton

    Is there a particular sign that indicates that it is a memory leak? I’ve observed this phenomenon for a while; memory usage does quickly increase, but the rate of increase slows and usage plateaus.

  2. Alan Noble reporter

    There appears to be no plateauing or slowdown, etc. Memory increases monotonically until it exhausts all available memory and revid-cli crashes.

    It is readily reproducible (within minutes).

  3. Saxon Milton

    wow okay, that’s bad, I’ll have a look.
    What are your MTSRBSize and MTSRBElementSize vars set to (if being set)?

  4. Alan Noble reporter

    MTSRBElementSize is 200000 and MTSRBSize is the default.

    FYI, I’ve been repro’ing sending to a standalone vidgind and simultaneously live streaming via HLS.

  5. Saxon Milton

    Okay I’m going to do some testing to try and narrow down what the cause is. If you wanted to try something, set MTSRBSize to 100. I’m interested to see how differences in the ring buffer sizes affect the behaviour.

  6. Saxon Milton

    Really? I’ve had revid-cli running on a pi zero for a couple of hours… for the past hour mem usage has stayed at 16.2%. This is with MTSRBSize=100 and MTSRBElementSize=300000. I’m officially confused if you’re still seeing the same behaviour. The only difference I think there would be between the zero I’m using and yours is that you’re using the latest version of raspbian ?

  7. Saxon Milton

    What do you have MinFrames set to (if set)? and what bitrate (if set)? I will try to replicate your conditions.

  8. Alan Noble reporter

    pi@PI000012:~ $ go version
    go version go1.13 linux/arm

    pi@PI000012:~ $ cat /etc/os-release
    PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
    NAME="Raspbian GNU/Linux"
    VERSION_ID="10"
    VERSION="10 (buster)"

  9. Alan Noble reporter

    MinFrames and bitrate are not set. Everything is defaults except for MTSRBSize and MTSRBElementSize. The latter is still 200000. I will bump that up now.

  10. Alan Noble reporter

    Please move to Buster (v10), which has been out for a while. I’m configuring all of our new cameras to use it.

  11. Saxon Milton

    Do you have a stretch image handy ? You could try that with same vars and see how it goes. I’ll have to download buster (it’ll take a while on my home conn)
    EDIT: shouldn’t take too long - I’m going with buster lite

  12. Alan Noble reporter

    No, I don’t have any Stretch images any more. Do you just want to pick up PI00012 and play with it?

  13. Saxon Milton

    I reckon I’ll just update the pi I’ve got to buster doing this then if that doesn’t give me any answers I’ll swing by and pick up PI00012

  14. Log in to comment