-
-
Notifications
You must be signed in to change notification settings - Fork 189
Memory leak in higher-order functions #1907
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
Conversation
|
@wolfgangmm looks very interesting... So is it the case that a If that is the case. Do we not need to make further fixes to classes such as:
|
|
@adamretter I wrapped all occurrences I found into try-with-resource, but will recheck the ones you mentioned. I think I covered them all though. |
|
@wolfgangmm does this mean we should update the code listing in Creating XQuery Modules? |
|
@wolfgangmm call let me know. I will then merge once you give me the "go ahead" |
|
NB: The appveyor failure was because the CI tests exceeded 60 minutes on one of the 4 tested environments, |
|
@wolfgangmm Thank you very much for your hard work in discovering this problem and fixing it. You mentioned on last week's call that your fix might require an API change, but I see that you've tagged this as targeting 4.2.0. I take it that you found a solution without an API change? |
|
@joewiz the API change I first considered was to allow more than two states for |
3360e5d to
179c22e
Compare
|
@adamretter ok, I checked and found three more cases where |
|
|
||
| public void setClosureVariables(List<ClosureVariable> vars) { | ||
| this.closureVariables = vars; | ||
| if (vars != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check your indenting ? for future commits
|
@wolfgangmm I have merged this because it is a definetly improvement. However, I have some concerns that there maybe yet more cases. How do we handle the case where a function reference is used for a variable declaration, and also for an external variable declaration? For example in XSuite's declare variable $local:some-compare-fun := function($a, $b) {
$a gt $b
}; |
|
@adamretter For Java code just make sure |
|
@wolfgangmm Thanks. Got it :-) |
Most functions which take a function item as argument are leaking memory. This includes nearly all functions on arrays and maps, but also
for-eachand similar. The memory leak will at least result in higher memory consumption but frequently leads to a complete system breakdown on production servers facing higher traffic.The PR does two things to fix the issue:
FunctionReferencenow implementsClosableso the caller can make sure temporary objects are cleared after the function item was used. Existing code will continue to work, but all core functions have been changed accordingly.