fix some memory leaks
Merge pull request #548 from minorua/raster_memory_leaks

Fix some memory leaks Fix #6795