Fixed the outofmemory crash

Signed-off-by: Marfyy <martinsafsten@gmail.com>