limix / glimix-core

Fast inference for Generalised Linear Mixed Models.
MIT License
11 stars 6 forks source link

Memory leak due to the use of functools lru_cache with class methods #15

Closed tohein closed 3 years ago

tohein commented 3 years ago

Hi, class method _logdetXX of LMM is cached using functools lru_cache. Calling .fit() or .lml(), which both rely on _logdetXX will prevent the LMM instance to be accessible to garbage collection until the cache is cleared (and listeners are removed, see issue #14).

https://github.com/limix/glimix-core/blob/8cd41cebf6e1e46f298dfd2533a87741bd7a3a6d/glimix_core/lmm/_lmm.py#L457

See also https://stackoverflow.com/questions/33672412/python-functools-lru-cache-with-class-methods-release-object

Best, Tobias

horta commented 3 years ago

I believe the version 3.1.12 fixes that issues. Thank you again for reporting it!