Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant