I was used to use code block {} in order to separate logics, for example in report generator code while chaining report sections. But recently I noticed that my application was using a lot of heap memory while processing 6Gb of numerical series, and after some investigations I've found that all loaded series was kept in memory even once we exit the block. Thanks to google group and contributors.

The code example which fails with an OutOfMemoryError (using locally{} locally{} locally{} will give the same problem)

The simple work around :