|
Any way to cut down on memory footprint?: msg#00410lang.scala
I did some tests of what kind of memory footprint some sample operations have. I did a test where I generate 10,000,000 random doubles (generated by calling nextGaussian() in java.util.Random), storing them in an ArrayBuffer, and the memory usage was about 250 MB. Seems like a bit much. Anything I can do about this? Doing the same thing with 20,000,000 instead of 10,000,000 gave an out of memory error. Is there any way to give the JVM a bigger heap size to work with when running Scala code? Here's the code I used, in case it matters. import java.util.{Date, Random} import scala.collection.mutable.ArrayBuffer object randtest { def main(args: Array[String]) { val cnt = Integer.parseInt(args(0)) val rnd = new Random() val buf = new ArrayBuffer[Double] val start = System.currentTimeMillis for(val i <- Iterator.range(0,cnt)) { buf += rnd.nextGaussian } val end = System.currentTimeMillis val diff = (end - start)/1000.0 Console.println(diff + "s") Console.readLine // just so we can see how much memory is being used } } Warren |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | two things about defs: 00410, Alexander Sergeev |
|---|---|
| Next by Date: | Re: two things about defs: 00410, Burak Emir |
| Previous by Thread: | two things about defsi: 00410, Alexander Sergeev |
| Next by Thread: | Re: Any way to cut down on memory footprint?: 00410, Warren Henning |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |