From 0faee70204e91827a1e8f5ba6c0a2b5d61e9bbb1 Mon Sep 17 00:00:00 2001 From: daid Date: Mon, 12 Jan 2015 13:57:11 +0100 Subject: [PATCH] Improve memory handling. --- Cura/util/bigDataStorage.py | 4 ++-- Cura/util/sliceEngine.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cura/util/bigDataStorage.py b/Cura/util/bigDataStorage.py index d1c4c86b..b3894dac 100644 --- a/Cura/util/bigDataStorage.py +++ b/Cura/util/bigDataStorage.py @@ -13,7 +13,7 @@ class BigDataStorage(object): def write(self, data): self._active.write(data) - if self._active.tell() > 1024 * 1024 * 100: + if self._active.tell() > 1024 * 1024 * 50: self._active = StringIO.StringIO() self._list.append(self._active) @@ -39,11 +39,11 @@ class BigDataStorage(object): data = self._list[0].getvalue() block0 = data[0:2048] block1 = StringIO.StringIO() + self._list[0] = StringIO.StringIO() block1.write(data[2048:]) self._list.insert(1, block1) for key, value in dictionary.items(): block0 = block0.replace(key, str(value)) - self._list[0] = StringIO.StringIO() self._list[0].write(block0) def __len__(self): diff --git a/Cura/util/sliceEngine.py b/Cura/util/sliceEngine.py index cf2d16f7..f4e521e2 100644 --- a/Cura/util/sliceEngine.py +++ b/Cura/util/sliceEngine.py @@ -298,7 +298,10 @@ class Engine(object): def _runEngine(self, scene, overrides, old_thread): if old_thread is not None: if self._process is not None: - self._process.terminate() + try: + self._process.terminate() + except: + pass old_thread.join() self._callback(-1.0) @@ -427,6 +430,7 @@ class Engine(object): self._callback(-1.0) self._process = None except MemoryError: + traceback.print_exc() self._result.addLog("MemoryError") self._callback(-1.0) -- 2.30.2