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 or endless loop in v1.3.0 #98

Closed
rny opened this issue Jun 23, 2024 · 5 comments
Closed

memory leak or endless loop in v1.3.0 #98

rny opened this issue Jun 23, 2024 · 5 comments

Comments

@rny
Copy link

rny commented Jun 23, 2024

after upgrade xpath v1.2.5 => v1.3.0 ( not change anything else)
our app memory keep increasing until OOM and CPU keeps 100%

I found a new loop was added in func (t *NodeIterator) MoveNext() bool
is it cause endless loop in some case?

@zhengchun
Copy link
Contributor

v1.3.0 changes a lot of code. https://github.com/antchfx/xpath/commits/master/

The best way is give your xpath expression to cause CPU high, let me test it.

@zhengchun
Copy link
Contributor

can you remove this code to disable caches and test again?

xpath/xpath.go

Line 96 in 4b4638b

id := getHashCode(n.Copy())

zhengchun added a commit that referenced this issue Jun 23, 2024
…query` packages re-use the cached element in some cases. #94
@rny
Copy link
Author

rny commented Jun 28, 2024

I noticed 1.3.1 removed that loop. I have tested these upgrades

go: upgraded github.com/antchfx/xmlquery v1.3.18 => v1.4.1
go: upgraded github.com/antchfx/xpath v1.2.5 => v1.3.1

the v1.3.1 CPU and memory is ok

@zhengchun
Copy link
Contributor

zhengchun commented Jun 28, 2024

I guess the high CPU is caused by the thread deadlock when application run in the multiple goroutines that reused cached expr object. so I removed those loop code. antchfx/htmlquery#58

@rny
Copy link
Author

rny commented Jul 5, 2024

agree. our app use xpath inside go { } a lot.

@rny rny closed this as completed Jul 12, 2024
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