-
-
Notifications
You must be signed in to change notification settings - Fork 905
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 when using Nokogiri::XML::Builder with XML namespaces #1771
Comments
Thanks for reporting. I'll investigate this weekend. |
I've reproduced this memory leak. Looking now! |
OK, I believe I've fixed this. Will be in 1.8.4 presuming the builds go green. Thanks so much for the bug report, and the thorough and complete analysis that you did! Also, thanks for using the bug-report template. ♥ ♥ ♥ |
Thanks for the fix! 👍 |
We also found that the leak can be avoided in versions < 1.8.4 when setting the namespace like this |
sanitize 4.6.6 has this optimization that will benefit Markdown rendering: rgrove/sanitize#183 nokogiri 1.4.4 has this memory leak fix: sparklemotion/nokogiri#1771
sanitize 4.6.6 has this optimization that will benefit Markdown rendering: rgrove/sanitize#183 nokogiri 1.4.4 has this memory leak fix: sparklemotion/nokogiri#1771 This mirrors changes for https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20795.
What problems are you experiencing?
Memory usage (VSZ and RSS) grows uncontrollably when using
Nokogiri::XML::Builder
with XML namespaces.What's the output from
nokogiri -v
?Can you provide a self-contained script that reproduces what you're seeing?
In fact, even the following snippet is enough to observe the memory leak, although arguably incomplete without the namespace declaration:
The memory leak seems to be provoked solely by specifying a namespace prefix in the element name (here
env:
).Here's a script doing essentially the same but with more informational output:
The output also confirms that it's not Ruby objects being leaked, as the number of Ruby objects does not change. Only VSZ and RSS grow.
According to Valgrind, most memory
definitely lost
is allocated in a function calledxmlStrndup()
innokogiri.so
:My wild guess is that the strings returned by
xmlStrndup()
should have been freed byrelink_namespace()
in xml_node.c, but I'm no expert in C.The text was updated successfully, but these errors were encountered: