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

implicit summoning of JsArray ToEntityMarshaller consumes all compiler memory #646

Open
jmcnulty-mosaic opened this issue Oct 18, 2021 · 0 comments

Comments

@jmcnulty-mosaic
Copy link

jmcnulty-mosaic commented Oct 18, 2021

Adding the line: val _ = implicitly[ToEntityMarshaller[JsArray]] to a scala program that usually compiles in less than 10 seconds and less than 2GB heap causes it to "run forever" even if I give it 8GB heap (it eventually complains about GC at the 2GB heap level)

The line above simply distills the problem, normally I would hit this when turning a Play Json object that contains (or is) a JsArray into an HttpEntity when, for example, rendering an HTTP Response in akka http.

If I provide an implicit marshaller in the local scope, then (a) the compiler complains that I have an unused local val and (b) completes compilation as normal so it appears to be taking advantage of the Marshaller nevertheless.

implicit val _ = Marshaller.strict[JsArray, MessageEntity] { t =>
        Marshalling.WithFixedContentType(ContentTypes.`application/json`, () => {
             ByteString(Json.stringify(t).getBytes)
        })
}
  • scala 2.12.12
  • akka 2.6.14
  • "de.heikoseeberger" %% "akka-http-play-json" % "1.29.1"
  • "com.typesafe.play" %% "play-json" % "2.9.1"
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

1 participant