StuffAnThings / qbit_manage

This tool will help manage tedious tasks in qBittorrent and automate them. Tag, categorize, remove Orphaned data, remove unregistered torrents and much much more.
MIT License
635 stars 41 forks source link

[Bug]: Memory leak after 4.1.3 release #552

Closed claabs closed 1 month ago

claabs commented 1 month ago

Describe the Bug

On 2024-05-06, my container updated to the 4.1.3 version from the latest tag. In my metrics, I can see a gradual increase in memory usage for the container. It amounts to an additional 33MiB per run.

My config also runs with environment variable: QBT_SCHEDULE=180

Config

# This is an example configuration file that documents all the options.
# It will need to be modified for your specific use case.
# Please refer to the link below for more details on how to set up the configuration file
# https://github.com/StuffAnThings/qbit_manage/wiki/Config-Setup

commands:
  # The commands defined below will IGNORE any commands used in command line and docker env variables.
  dry_run: false
  cross_seed: false
  recheck: false
  cat_update: false
  tag_update: false
  rem_unregistered: false
  tag_tracker_error: false
  rem_orphaned: false
  tag_nohardlinks: true
  share_limits: false
  skip_qb_version_check: true
  skip_cleanup: false

qbt:
  # qBittorrent parameters
  host: 172.17.0.1:8080
  user: <redacted>
  pass: <redacted>

settings:
  force_auto_tmm: false # Will force qBittorrent to enable Automatic Torrent Management for each torrent.
  tracker_error_tag: issue # Will set the tag of any torrents that do not have a working tracker.
  nohardlinks_tag: obsolete # Will set the tag of any torrents with no hardlinks.
  share_limits_tag: ~share_limit # Will add this tag when applying share limits to provide an easy way to filter torrents by share limit group/priority for each torrent
  ignoreTags_OnUpdate: # When running tag-update function, it will update torrent tags for a given torrent even if the torrent has at least one or more of the tags defined here. Otherwise torrents will not be tagged if tags exist.
  - noHL
  - issue
  - cross-seed
  share_limits_min_seeding_time_tag: MinSeedTimeNotReached
  share_limits_min_num_seeds_tag: MinSeedsNotMet
  share_limits_last_active_tag: LastActiveLimitNotReached
  cross_seed_tag: cross-seed
  cat_filter_completed: true
  share_limits_filter_completed: true
  tag_nohardlinks_filter_completed: true
  force_retag_all: false
directory:
  # Do not remove these
  # Cross-seed var: </your/path/here/>  # Output directory of cross-seed
  # root_dir var: </your/path/here/>  # Root downloads directory used to check for orphaned files, noHL, and RecycleBin.
  # <OPTIONAL> remote_dir var: </your/path/here/>  # Path of docker host mapping of root_dir.
  # remote_dir must be set if you're running qbit_manage locally and qBittorrent/cross_seed is in a docker
  # remote_dir should not be set if qbit_manage is running in a container
  # <OPTIONAL> recycle_bin var: </your/path/here/>   # Path of the RecycleBin folder. Default location is set to remote_dir/.RecycleBin
  # <OPTIONAL> torrents_dir var: </your/path/here/>  # Path of the your qbittorrent torrents directory. Required for `save_torrents` attribute in recyclebin
  # <OPTIONAL> orphaned_dir var: </your/path/here/>  # Path of the the Orphaned Data folder. This is similar to RecycleBin, but only for orphaned data.
  cross_seed: /storage/cross-seed/
  root_dir: /storage/downloads/

  remote_dir: /storage/downloads/
  recycle_bin: /storage/downloads/.RecycleBin
  torrents_dir: /qbittorrent/qBittorrent/BT_backup/
cat:

cat_change:

tracker:
  # The "other" key is a special keyword and if defined will tag any other trackers that don't match the above trackers into this tag
  other:
    tag: other

nohardlinks:
  # Tag Movies/Series that are not hard linked outside the root directory
  # Mandatory to fill out directory parameter above to use this function (root_dir/remote_dir)
  # This variable should be set to your category name of your completed movies/completed series in qbit. Acceptable variable can be any category you would like to tag if there are no hardlinks found
- radarr
- radarr-small
- tv-sonarr
- tv-sonarr-small
- readarr

share_limits:
  default:
    priority: 999
    max_ratio: -1
    max_seeding_time: -1
    cleanup: false

recyclebin:
  # Recycle Bin method of deletion will move files into the recycle bin (Located in /root_dir/.RecycleBin) instead of directly deleting them in qbit
  # By default the Recycle Bin will be emptied on every run of the qbit_manage script if empty_after_x_days is defined.
  enabled: true
  # <OPTIONAL> empty_after_x_days var:
  # Will automatically remove all files and folders in recycle bin after x days. (Checks every script run)
  # If this variable is not defined it, the RecycleBin will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 60
  # <OPTIONAL> save_torrents var:
  # If this option is set to true you MUST fill out the torrents_dir in the directory attribute.
  # This will save a copy of your .torrent and .fastresume file in the recycle bin before deleting it from qbittorrent
  save_torrents: true
  # <OPTIONAL> split_by_category var:
  # This will split the recycle bin folder by the save path defined in the `cat` attribute
  # and add the base folder name of the recycle bin that was defined in the `recycle_bin` sub-attribute under directory.
  split_by_category: false

orphaned:
  # Orphaned files are those in the root_dir download directory that are not referenced by any active torrents.
  # Will automatically remove all files and folders in orphaned data after x days. (Checks every script run)
  # If this variable is not defined it, the orphaned data will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 60
  # File patterns that will not be considered orphaned files. Handy for generated files that aren't part of the torrent but belong with the torrent's files
  exclude_patterns:
  - '**/.DS_Store'
  - '**/Thumbs.db'
  - '**/@eaDir'
  - /data/torrents/temp/**
  - '**/*.!qB'
  - '**/*_unpackerred'

apprise:

notifiarr:

webhooks:
  error:
  run_start:
  run_end:
  function:
    cross_seed:
    recheck:
    cat_update:
    tag_update:
    rem_unregistered:
    tag_tracker_error:
    rem_orphaned:
    tag_nohardlinks:
    share_limits:
    cleanup_dirs:

bhd:

Logs

https://gist.github.com/claabs/ff5ea43cecc782645ebaef0355f6d3e1

Screenshots

image

Installation

Docker

Version Number

4.1.3

What branch are you on?

master

bobokun commented 1 month ago

@claabs can you please switch over to develop branch and see if you're still having this issue? Thanks

claabs commented 1 month ago

Looks good, thanks! Here's a before and after: image

tordenflesk commented 1 month ago

I'm experiencing the same slow creep as well. Qbit_Manage 4.1.5, qBt 4.4.5, Python 3.10.

bobokun commented 1 month ago

This was fixed in 4.1.5