Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active December 20, 2015 03:49
Show Gist options
  • Save dacr/6065956 to your computer and use it in GitHub Desktop.
Save dacr/6065956 to your computer and use it in GitHub Desktop.
conceptual block doest not zero out references, so the following code fails with an OutOfMemoryError.
#!/bin/sh
exec scala -J-Xms80m -J-Xmx80m -deprecation -nocompdaemon "$0" "$@"
!#
def allocate(szInMb:Int=24) =
Array.fill[Byte](1024*1024*szInMb)(util.Random.nextInt(256).toByte)
def testit = {
val showStep = {var s=0 ; () => {s+=1 ; println(s"step$s")}}
{ showStep(); val x= allocate(20) }
{ showStep(); val x= allocate(20) }
{ showStep(); val x= allocate(20) }
{ showStep(); val x= allocate(20) }
}
testit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment