Closed skcc321 closed 3 years ago
@seuros @emaglio could you guys take a look at that please?
Thanks, this is great work!
I wonder why there are objects sticking around in the first place. Have you encountered this without dry-validation, too?
I faced with the issue on production. Due to urgency I had to do something ASAP. As a workaround, I switched reform to use ActiveModel validation on some services. Here is memory consumption graph before and after switching from "dry" to ActiveModel:
But we have other services where we still have dry + reform. That is why I started debug on dry contract first, but during investigation found not garbage collected arrays with references to the same constants.
Even with ActiveModel validation I noticed some (very) slow memory leak. But, that is much less dangerous.
I'll try to bring some evidences soon (unfortunately a bit loaded now)
Well, I'm happy to merge that fix if it's urgent?
Im testing it
OK. Looks like I'm wrong about that array initialization. GC can garbage collect it. Initially, I tried to reproduce it inside tests, and I noticed it using that setup. It is not reproducible with the current setup. So looks like that is not the case. I'll remove that part from the PR.
any updates on that? @seuros
@skcc321 I think we are good. I found another memory leak, but it seem that it coming from dry-validation. I will write a report soon.
@seuros if so, how soon it can be released?
This weekend for sure.
@skcc321 on rubygems.
@seuros thank you!
The issue was detected in
twoone places on each validation call:initialization new array with constants insideto reproduce: 1) install gem https://github.com/SamSaffron/memory_profiler 2) go to the repository and profile memory consumption by ruby script "mem_leak.rb".
3) download this PR and run it again.
here are results:
as a bonus, performance results: