Bug 1064126: be more efficient with canvas memory