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 in path method #179

Closed
vovanmozg opened this issue Jan 19, 2022 · 5 comments
Closed

Memory leak in path method #179

vovanmozg opened this issue Jan 19, 2022 · 5 comments

Comments

@vovanmozg
Copy link
Contributor

ruby 3.0.0
libxml-ruby: 3.2.1
libxml: 2.9.10
Debian 11

I added demo (using linux ps to measure memory consumption)
https://github.com/vovanmozg/libxml-ruby/blob/cf1cd5cd53d05f6af7f90c8b2ccb879f5c140f19/test/test_xpath.rb#L171-L178

def test_path_memory
 node = LibXML::XML::Node.new('node')
 p `ps -o rss= -p #{Process.pid}`.to_f
 1000000.times do
   node.path
 end
 p `ps -o rss= -p #{Process.pid}`.to_f
end

path implementation:

static VALUE rxml_node_path(VALUE self)

@vovanmozg vovanmozg changed the title Memory leak in path method Memory leak in path method Jan 19, 2022
@vovanmozg
Copy link
Contributor Author

vovanmozg commented Jan 19, 2022

Please, take a look at the quick solution
vovanmozg@5206247

@cfis
Copy link
Member

cfis commented Jan 22, 2022

That looks good - since you have the code already want to send in a pull request? Otherwise I can do it by hand.

@vovanmozg
Copy link
Contributor Author

I going to do some tests on my project and than to send in a pull request.

@cfis
Copy link
Member

cfis commented Jan 23, 2022

Sounds good - thanks.

@vovanmozg
Copy link
Contributor Author

#180

@cfis cfis closed this as completed Jan 24, 2022
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