0

so I'm trying to compile and run a scala project on a 512mb Digital Ocean server. Basically, the issue I'm running into is that when it starts compiling it pulls in all the dependencies, and ultimately runs out of memory. Is this normal? I know that the project I'd like to run doesn't need more than 512mb, and it would be a shame to have to increase the size just to make it compile. Am I doing something wrong here?

Here's my build.sbt, note this is using sbt.version 13.8

scalaVersion := "2.10.2"

libraryDependencies ++= {
  val akkaV = "2.1.4"
  val sprayV = "1.1.1"
  Seq(
    "com.typesafe.akka"      %%  "akka-actor"        % akkaV,
    "com.typesafe.akka"      %%  "akka-testkit"      % akkaV   % "test",
    "org.specs2"             %%  "specs2-core"       % "2.3.9" % "test",
    "org.twitter4j"          %   "twitter4j-stream"  % "4.0.2",
    "io.spray"               %   "spray-can"         % sprayV,
    "io.spray"               %   "spray-routing"     % sprayV,
    "io.spray"               %   "spray-client"      % sprayV,
    "io.spray"               %   "spray-testkit"     % sprayV,
    "io.spray"               %   "spray-json_2.10"   % "1.2.5",
    "com.github.nscala-time" %%  "nscala-time"       % "1.4.0",
    "com.codahale.metrics"   %   "metrics-core"      % "3.0.1",
    "org.elasticsearch"      %   "metrics-elasticsearch-reporter" % "2.0"
  )
}

enablePlugins(JavaAppPackaging)

//settings(com.typesafe.sbt.SbtNativePackager.packageArchetype.java_application: _*)

Revolver.settings
user2767260
  • 283
  • 2
  • 10
  • 512MB is pretty optimistic to compile a large project. You can try to set [SBT_OPTS](https://stackoverflow.com/questions/15280839/how-to-set-heap-size-for-sbt) to specify maximum heap and GC for sbt. – 0__ Jul 17 '15 at 19:32
  • So, essentially if I would like to use this 512mb server for my project I should probably just assemble a .jar and then send it to the server to be run? Well, something along those lines so that the server doesn't have to manage the compiling, I guess. – user2767260 Jul 17 '15 at 19:34
  • I don't know. Perhaps you can find JVM settings that make the GC kick in early enough to not exceed 512MB. But that's purely speculative. For assembly tasks I guess it will pull all jars at some point into memory. – 0__ Jul 17 '15 at 19:40
  • "I should probably just assemble a .jar and then send it to the server to be run" — yes, that sounds sensible to me. – Seth Tisue Jul 18 '15 at 14:48

1 Answers1

0

You can use a trick. Sbt has requirements to virtual memory (it ignores jvm heap options with low values), so turn on swap space (it's disabled by default in DO images). There is no affects on performance if real memory is enough.

Zernike
  • 1,758
  • 1
  • 16
  • 26