Skip to content

Memory usage grows indefinitely when repeatedly calling TALibFFI.xxx (memory leak?) #11

@tmac

Description

@tmac

Summary

When repeatedly calling TALibFFI.xxx in a long-running process, memory usage grows steadily and never stabilizes, suggesting a potential memory leak.

Environment

  • OS: macOS 14.5
  • Ruby version: 3.4
  • ta-lib-ffi version: 0.3.0
  • TA-Lib version: 0.6.4 (installed via Homebrew)

Reproduction

require 'ta_lib_ffi'

count = 0
100_000.times { 
  TALibFFI.ema([1,2,3,4,5,6,7,8,9,10,11,12,13,14], time_period: 14) 
  count         += 1
  rss           = `ps -o rss= -p #{Process.pid}`.to_i
  pointer_count = ObjectSpace.each_object(Fiddle::Pointer).count

  printf("\r%-60s", "Records: #{count}, Pointers: #{pointer_count}, Memory: #{rss} KB") 
}
  • Pointer count climbs, then drops (suggesting GC is cleaning them up)
  • However, overall RSS continues growing and never stabilizes

###Notes

  • The same test with ta-lib-python shows no memory growth.
  • Possibly related to TA-Lib or Fiddle holding references internally?

Would appreciate your thoughts. Thanks!

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