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 #229

Closed
collimarco opened this issue Apr 18, 2015 · 5 comments
Closed

Memory leak #229

collimarco opened this issue Apr 18, 2015 · 5 comments

Comments

@collimarco
Copy link

Even if I already mentioned this problem in #228 saying that I get a "Killed: 9" this is a totally independent problem from the segmentation fault and I think it deserves its own ticket.

Further investigating the "Killed: 9" I discovered (quite obvious) that the ruby process steadily increases memory usage.

The line responsible for this issue is:

@entity = Oj::Doc.open(@line)

In fact by simply substituting it with

@entity = JSON.parse(@line)

I get no problems with memory usage. (The above lines produce different objects, but this is not a problem, since in this demonstration @entity is never used. Also I could have simply removed the line instead of substituting it, but I have done this to prove that is not simply a problem with the garbage collector)

Adding @entity.closeafter the open doesn't solve the issue.

@ohler55
Copy link
Owner

ohler55 commented Apr 19, 2015

Once I get the file down loaded I'll take a look. The close should free memory.

On April 18, 2015 1:40:14 PM PDT, Marco Colli notifications@github.com wrote:

Even if I already mentioned this problem in
#228 saying that I get a "Killed:
9" this is a totally independent problem from the segmentation fault
and I think it deserves its own ticket.

Further investigating the "Killed: 9" I discovered (quite obvious) that
the ruby process steadily increases memory usage.

The line responsible for this issue is:

@entity = Oj::Doc.open(@line)

In fact by simply substituting it with

@entity = JSON.parse(@line)

I get no problems with memory usage. (The above lines produce different
objects, but this is not a problem, since in this demonstration
@entity is never used. Also I could have simply removed the line
instead of substituting it, but I have done this to prove that is not
simply a problem with the garbage collector)

Adding @entity.closeafter the open doesn't solve the issue.


Reply to this email directly or view it on GitHub:
#229

@collimarco
Copy link
Author

To reproduce the issue you can use this script:
https://gist.github.com/collimarco/677e059206854932f1c4#file-gistfile3-rb

@collimarco
Copy link
Author

Found out that this causes the issue:

    doc = Oj::Doc.open(line)
    create_item(doc) if fetch(doc, '/type') == 'item'
    doc.close

While this is correct and doesn't waste memory:

    Oj::Doc.open(line) do |doc|
      create_item(doc) if fetch(doc, '/type') == 'item'
    end

@ohler55
Copy link
Owner

ohler55 commented Apr 29, 2015

I believe this is fixed a release or two ago.

@collimarco
Copy link
Author

@ohler55 Sure, you have fixed it in version 2.12.4 a few days after my message. Thanks a lot! Now this issue can be closed.

agnessa added a commit to unepwcmc/SAPI that referenced this issue Apr 27, 2016
agnessa added a commit to unepwcmc/SAPI that referenced this issue Apr 29, 2016
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