memory management code bricks for JavaScript