You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
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:
object Parser {
+ val yaml = new Yaml(new SafeConstructor)
def fromInputStream(source: InputStream): Try[Parser] = Try {
- val yaml = new Yaml(new SafeConstructor)
val javaConfig = yaml.load(source).asInstanceOf[JMap[String, JList[JMap[String, String]]]]
val config = javaConfig.asScala.toMap.mapValues(_.asScala.toList.map(_.asScala.toMap.filterNot {
case (_ , value) => value eq null
Thoughts? I tried to submit this via PR, but i lack the permission in your repo.
The text was updated successfully, but these errors were encountered:
(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.)
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.
The text was updated successfully, but these errors were encountered: