-
-
Notifications
You must be signed in to change notification settings - Fork 812
JsonPointer
quadratic memory use: OOME on deep inputs
#736
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
Comments
Interesting. I will have to look into this a bit. My immediate thinking is that this might be an unfortunate side effect of attempting to retain lazily computed description for But it sounds like here it is more directly called as a side effect, causing every single pointer "node" to create and retain its full path description. |
Hmmmh. Unfortunately, looking at code involved, it is not the way I thought -- actual full path is eagerly constructed. This makes changing a whole lot more difficult and probably only doable for a new minor version (2.14). |
Can I make a case for Caffeine cache? The cache could be configured to hold onto a max number of pointer strings and to remove others on a LRU basis. If jackson were to buy into real LRU behaviour with its caches. The LRUMap could be rewritten to use a similar caffeine cache - like the one I support at https://github.com/pjfanning/jackson-caffeine-cache |
@pjfanning If we needed cache Caffeine is great. But in this case unfortunately caches would not really work, I think. Problem is rather that of how to remove eager construction and retaining of String representation while still allowing efficient operation for common usage. Caches are highly problematic for this usage due to various reasons, including lack of clear ownership ( |
Quick note: still thinking about how to tackle this problem. No solution yet, but one very preliminary idea is around a limit for "_asString" such that existing processing would only be applied for shorter paths (either by length of path representation or number of segments; whichever is easier to track), and different, more dynamic (and less pre-processing) approach was taken beyond that initial set. Note: marking as performance related since that label covers efficiency aspects too (excessive memory usage). |
Actually I have a bit more specific idea to consider: when constructing an instance, create full path for the deepest level -- but then for parent levels have reference to full path and length (from beginning), "leftstr". New
This would avoid eagerly allocating N String representations upon construction. It would not necessarily be optimal for use cases where I'll see if I can implement something along these lines: it seems doable without sacrificing backwards compatibility, and doable for 2.14 (but just to play it safe probably not for 2.13). |
JsonPointer
quadratic memory use: OOME on deep inputs
Finally found time to fix this; will be in 2.14.0 final. |
Adding https://github.com/nst/JSONTestSuite in rallyhealth/weePickle#106 uncovered that
JsonPointer
memory usage is quadratic over depth.-Xmx8g
is insufficient to create aJsonPointer
for 100k opening arrays without anOutOfMemoryError
.JsonPointer
seems to be a linked list where each node contains an_asString
field containing the full path to that node.Minimal test to repro the issue: 3764ff4
The text was updated successfully, but these errors were encountered: