Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak with MultiJSON.dump #204

Open
sethboyles opened this issue Aug 30, 2022 · 2 comments
Open

Memory leak with MultiJSON.dump #204

sethboyles opened this issue Aug 30, 2022 · 2 comments

Comments

@sethboyles
Copy link

In a Rails app serving JSON responses, we noticed the following memory leak:

allocated by memory (61079397) (in bytes)
==============================
  61079397  /var/vcap/data/packages/cloud_controller_ng/46a8cc86e43a32e41d5b5e91e6983e75542ed547/gem_home/ruby/3.1.0/gems/multi_json-1.15.0/lib/multi_json/adapters/oj.rb:56

object count (1)
==============================
  1  /var/vcap/data/packages/cloud_controller_ng/46a8cc86e43a32e41d5b5e91e6983e75542ed547/gem_home/ruby/3.1.0/gems/multi_json-1.15.0/lib/multi_json/adapters/oj.rb:56

Memory would not be freed when the request ended, and eventually we would have to restart our process. We noticed the same behavior when using yajl.

Bypassing MultiJSON entirely resolved the issue for us.

More details here: cloudfoundry/capi-release#262 (comment)

@rwz
Copy link
Member

rwz commented Aug 31, 2022

This is unfortunate. Both Oj and yajl are native extensions written in C, so there's not much MultiJSON can do about it here.

I recommend switching to a different adapter or stop using MultiJSON altogether as an option to remediate memory leaks.

@sethboyles
Copy link
Author

sethboyles commented Aug 31, 2022

Well I think the memory leak is only in MultiJSON, to clarify. Using OJ.dump seems fine. It's only when using Oj via MultiJSON that we witness the memory leak. Sorry if that wasn't clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants