Skip to content

GenTL Producer Memory Leak — ImageAcquirer create/destroy cycle #502

Description

@jsiverskog

Describe the Issue
the mv_gen_tl_producer leaks approximately 10 MB of native memory every time an ImageAcquirer is created and destroyed. memory is never reclaimed.

To Reproduce
run the below code.

Sample Code
I can show a piece of code that demonstrates the reported phenomenon:

  • Yes
  • No
import resource
from harvesters.core import Harvester

def rss_mb():
    return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024

h = Harvester()
h.add_file("file.cti")
h.update()

for i in range(20):
    before = rss_mb()
    ia = h.create(0)
    ia.start()
    with ia.fetch(timeout=2) as buf:
        pass
    ia.stop()
    ia.destroy()
    after = rss_mb()
    print(f"iter={i} rss=+{after - before:.1f} MB  total={after:.1f} MB")

If applicable, please paste the actual output (its whole traceback, etc) here:

iter=0 rss=+27.3 MB  total=80.8 MB
iter=1 rss=+13.2 MB  total=93.9 MB
iter=2 rss=+8.3 MB  total=102.2 MB
iter=3 rss=+8.5 MB  total=110.7 MB
iter=4 rss=+8.2 MB  total=118.9 MB
iter=5 rss=+8.2 MB  total=127.0 MB
iter=6 rss=+6.2 MB  total=133.2 MB
iter=7 rss=+8.1 MB  total=141.3 MB
iter=8 rss=+8.2 MB  total=149.4 MB
iter=9 rss=+8.2 MB  total=157.6 MB
iter=10 rss=+8.2 MB  total=165.8 MB
iter=11 rss=+8.2 MB  total=173.9 MB
iter=12 rss=+8.2 MB  total=182.1 MB
iter=13 rss=+4.7 MB  total=186.8 MB
iter=14 rss=+8.5 MB  total=195.3 MB
iter=15 rss=+8.2 MB  total=203.5 MB
iter=16 rss=+8.2 MB  total=211.6 MB
iter=17 rss=+8.2 MB  total=219.8 MB
iter=18 rss=+8.2 MB  total=228.0 MB
iter=19 rss=+5.2 MB  total=233.1 MB

Expected Behavior
memory usage should stabilize and not increase.

Configuration

  • OS: Linux 6.12.75+rpt-rpi-2712 [arm64]
  • Python: 3.12.13
  • Harvester: 1.4.3
  • GenTL Producer: BAI BVA - Balluff Impact Acquire 3.6.3
  • Camera: Hikrobot MV-CS050-10UM

Reproducibility

This phenomenon can be stably reproduced:

  • Yes
  • No.

i don't know where things happen, perhaps this issue is in the gentl producer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions