Handle memory safely.