mirror of
https://github.com/Escartem/AnimeWwise.git
synced 2026-06-05 07:50:23 +08:00
fix memory issues
This commit is contained in:
10
allocator.py
10
allocator.py
@@ -1,5 +1,4 @@
|
||||
# memory manager to prevent redundant calls to files and save up disk usage
|
||||
# may cause massive ram usage if we input too many pck at once, fix required
|
||||
import os
|
||||
import mmap
|
||||
|
||||
@@ -10,13 +9,14 @@ class Allocator:
|
||||
def load_file(self, path):
|
||||
filename = os.path.basename(path)
|
||||
with open(path, "r+b") as f:
|
||||
mmap_object = mmap.mmap(f.fileno(), 0)
|
||||
|
||||
self.files[filename] = mmap_object,
|
||||
mmap_object = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
|
||||
self.files[filename] = mmap_object
|
||||
|
||||
def read_at(self, file, offset, size):
|
||||
data = self.files[file][offset:offset+size]
|
||||
mmap_object = self.files[file]
|
||||
mmap_object.seek(offset)
|
||||
data = mmap_object.read(size)
|
||||
return data
|
||||
|
||||
def free_mem(self):
|
||||
|
||||
1
app.py
1
app.py
@@ -221,6 +221,7 @@ class AnimeWwise(QMainWindow):
|
||||
# misc
|
||||
def resetApp(self):
|
||||
self.resetTreeWidget()
|
||||
self.extract.reset()
|
||||
self.tabs.setTabEnabled(0, True)
|
||||
self.tabs.setTabEnabled(1, False)
|
||||
self.tabs.setTabEnabled(2, False)
|
||||
|
||||
@@ -14,7 +14,6 @@ from allocator import Allocator
|
||||
cwd = os.getcwd()
|
||||
path = lambda path: os.path.join(cwd, path)
|
||||
call = lambda args: subprocess.call(args, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
allocator = Allocator()
|
||||
|
||||
skips = "000000000" # used for debugging
|
||||
|
||||
@@ -40,6 +39,8 @@ class WwiseExtract:
|
||||
"temp": tempfile.TemporaryDirectory()
|
||||
}
|
||||
|
||||
self.allocator = Allocator()
|
||||
|
||||
# self.progress = progress
|
||||
|
||||
def path(self, base, path):
|
||||
@@ -374,3 +375,9 @@ class WwiseExtract:
|
||||
# allocator.load_file(os.path.join(_input, "2050.pck"))
|
||||
# allocator.read_at("2050.pck", 0, 0)
|
||||
pass
|
||||
### other ###
|
||||
|
||||
def reset(self):
|
||||
if self.mapper is not None:
|
||||
self.mapper.reset()
|
||||
self.allocator.free_mem()
|
||||
|
||||
2
gui.ui
2
gui.ui
@@ -152,7 +152,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="assetMapLabel">
|
||||
<property name="text">
|
||||
<string>Asset map (optional)</string>
|
||||
<string>Asset map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user