gradient: fixed a memory leak