Trying to get better memory management