[sc-memory] Fix error with elements free