Open dgohlke opened 6 years ago
Yes, an update to the documentation would be much appreciated! Are you able to open a PR from a personal fork?
(Oh, and about the position of the Yaml
instantiation: my understanding was that Yaml
is not thread-safe and that it's therefore not appropriate for a val
in an object. This may have changed since the last time I looked at the SnakeYAML code / docs in detail, but I doubt it.)
Yaml is not thread-safe means that you cannot call methods of the same instance from different threads.
I do not see how it might be connected to val
I'm using uap-scala in a mobile backend that services 4.5 million requests a day. While recently debugging a memory leak, I discovered snakeyaml consuming an excessive amount of heap memory.
org.yaml.snakeyaml.error.Mark
was consuming 115 MB with nearly 3 million instances. Using https://github.com/jrudolph/sbt-dependency-graph, I found uap-scala was the only dependency in our build that was dependent on snakeyaml.We have a playframework application setup with a logging filter similar to this (simplified):
The above problem exists with the above code. Here's what we did to fix it:
We moved the
Parser.default
instantiation up into the root of the class. Now we no longer have the memory leak.I'm wondering if either the documentation can be updated to suggest following a pattern of instantiating then parsing, or if this can be handled from a code perspective. In fact, I believe this change might address the problem:
Thoughts? I tried to submit this via PR, but i lack the permission in your repo.