mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Clear error.__traceback__ to prevent memory leaks
Summary: When a formula raises an exception, we store that in the cell in memory. In Python 3, exceptions have a `__traceback__` attribute, which includes all the stack frames and local variables. This has huge memory leak potential. We already strategically format the exception when needed, we don't need to keep storing the actual traceback object. Test Plan: Manually tested that tracebacks are still sensible. To check the effect on memory usage, made a simple test doc with 30k rows all containing an exception, and here's what ps aux says: ``` %MEM VSZ RSS before: 2.4 681996 588828 after: 1.6 499052 405712 ``` Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3505
This commit is contained in:
parent
808aacdc52
commit
8bab8c18fa
@ -275,6 +275,7 @@ class RaisedException(object):
|
|||||||
self._message = None
|
self._message = None
|
||||||
if error is not None:
|
if error is not None:
|
||||||
self._fill_from_error(self.has_user_input(), include_details)
|
self._fill_from_error(self.has_user_input(), include_details)
|
||||||
|
error.__traceback__ = None
|
||||||
|
|
||||||
def encode_args(self):
|
def encode_args(self):
|
||||||
if self._encoded_error is not None:
|
if self._encoded_error is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user