rinohtype icon indicating copy to clipboard operation
rinohtype copied to clipboard

Investigate whether memory usage can be reduced

Open brechtm opened this issue 9 years ago • 2 comments

Rendering the Sphinx documentation takes about 2GB of memory.

Top 10 lines
#1: pdf/__init__.py:143: 400.0 MiB
    parent_canvas.write(self.getvalue())
#2: rinoh/util.py:115: 189.0 MiB
    cache[args_kwargs] = cache_value
#3: rinoh/dimension.py:156: 88.0 MiB
    self.addends = list(addends)
#4: rinoh/layout.py:218: 58.6 MiB
    self._self_cursor = Dimension(0)  # initialized at container's top edge
#5: pdf/__init__.py:136: 58.2 MiB
    self.fonts = {}
#6: rinoh/style.py:290: 54.2 MiB
    if not hasattr(styled, attr) or getattr(styled, attr) != value:
#7: rinoh/style.py:317: 48.1 MiB
    return type(self)(*(child_selector for selector in self.selectors
#8: pdf/__init__.py:137: 47.5 MiB
    self.images = {}
#9: packaging/version.py:353: 41.2 MiB
    reversed(release),
#10: pdf/__init__.py:344: 35.9 MiB
    self.annotation = annotation
11976 other: 819.5 MiB
Total allocated size: 1840.2 MiB

See:

  • https://docs.python.org/3/library/tracemalloc.html
  • https://bitbucket.org/haypo/tracemallocqt

brechtm avatar Aug 10 '16 09:08 brechtm

Down to 1 GB thanks to 3660222.

brechtm avatar Aug 10 '16 13:08 brechtm

Shaved off another 140 MB in 3503748 (wip/canvas_memory branch).

brechtm avatar Aug 10 '16 13:08 brechtm