Force garbage collection during ProcessSlicedLayersJob

For some reason, Python likes to hold on to LayerData and friends.
Forcing a GC run here will clean them up properly.

Contributes to CURA-2406
This commit is contained in:
Arjen Hiemstra 2016-09-22 00:57:14 +02:00
parent 8e5183bad4
commit baa24370f6

View file

@ -1,6 +1,8 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
import gc
from UM.Job import Job from UM.Job import Job
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
@ -64,6 +66,12 @@ class ProcessSlicedLayersJob(Job):
self._progress.hide() self._progress.hide()
return return
# Force garbage collection.
# For some reason, Python has a tendency to keep the layer data
# in memory longer than needed. Forcing the GC to run here makes
# sure any old layer data is really cleaned up before adding new.
gc.collect()
mesh = MeshData() mesh = MeshData()
layer_data = LayerDataBuilder.LayerDataBuilder() layer_data = LayerDataBuilder.LayerDataBuilder()
layer_count = len(self._layers) layer_count = len(self._layers)