Skip to content

Rails app: NoMemoryError: Too deeply nested #204

Open
@incorvia

Description

@incorvia

When using Ruby on Rails I'm running into "NoMemoryError: Too deeply nested." with OJ's serialization within this gem. The suggested solution worked if I edited the OJ 'mode' to 'compat' and added the 'use_as_json' flag as follows:

    OJ_OPTIONS = {
      mode: :compat,
      # use ruby's built-in serialization.  If nil, OJ seems to default to ~15 decimal places of precision
      float_precision: 0,
      use_as_json: true
    }.freeze

The fact that no one else runs into this makes me wonder if maybe there is something about Rails specifically that is causing this though haven't tracked it down. If it's possible to modify these OJ options for everyone and tests still pass it could be suggested as a solution.

I'm happy to offer a PR if it would be accepted.

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