fix invalid size of memory to clear