about summary refs log tree commit diff
path: root/kindlecomicconverter
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2017-03-19 07:48:39 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2017-03-19 07:48:39 +0100
commit1895aa127dde2eb28864184ef33e6627d97e06a4 (patch)
tree6fea30f4b956dcc067ddff596faf7c19d8af3278 /kindlecomicconverter
parentUpdate README.md (diff)
downloadkcc-1895aa127dde2eb28864184ef33e6627d97e06a4.tar.gz
kcc-1895aa127dde2eb28864184ef33e6627d97e06a4.tar.bz2
kcc-1895aa127dde2eb28864184ef33e6627d97e06a4.zip
Decrease memory usage
Diffstat (limited to 'kindlecomicconverter')
-rwxr-xr-xkindlecomicconverter/comic2ebook.py8
-rw-r--r--kindlecomicconverter/comic2panel.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py
index f5c6320..f2d0fc6 100755
--- a/kindlecomicconverter/comic2ebook.py
+++ b/kindlecomicconverter/comic2ebook.py
@@ -455,7 +455,7 @@ def buildEPUB(path, chapterNames, tomeNumber):
 
 def imgDirectoryProcessing(path):
     global workerPool, workerOutput
-    workerPool = Pool()
+    workerPool = Pool(maxtasksperchild=100)
     workerOutput = []
     options.imgMetadata = {}
     options.imgOld = []
@@ -1185,9 +1185,11 @@ def makeMOBI(work, qtGUI=None):
         threadNumber = 1
     elif 2 < availableMemory <= 4:
         threadNumber = 2
-    else:
+    elif 4 < availableMemory <= 8:
         threadNumber = 4
-    makeMOBIWorkerPool = Pool(threadNumber)
+    else:
+        threadNumber = None
+    makeMOBIWorkerPool = Pool(threadNumber, maxtasksperchild=10)
     for i in work:
         makeMOBIWorkerPool.apply_async(func=makeMOBIWorker, args=(i, ), callback=makeMOBIWorkerTick)
     makeMOBIWorkerPool.close()
diff --git a/kindlecomicconverter/comic2panel.py b/kindlecomicconverter/comic2panel.py
index e173575..8618cda 100644
--- a/kindlecomicconverter/comic2panel.py
+++ b/kindlecomicconverter/comic2panel.py
@@ -238,13 +238,13 @@ def main(argv=None, qtGUI=None):
             work = []
             pagenumber = 1
             splitWorkerOutput = []
-            splitWorkerPool = Pool()
+            splitWorkerPool = Pool(maxtasksperchild=10)
             if options.merge:
                 print("Merging images...")
                 directoryNumer = 1
                 mergeWork = []
                 mergeWorkerOutput = []
-                mergeWorkerPool = Pool()
+                mergeWorkerPool = Pool(maxtasksperchild=10)
                 mergeWork.append([options.targetDir])
                 for root, dirs, files in os.walk(options.targetDir, False):
                     dirs, files = walkSort(dirs, files)