stacktrace.js icon indicating copy to clipboard operation
stacktrace.js copied to clipboard

Extremely high memory usage

Open johannesjo opened this issue 5 years ago • 5 comments

For a larger codebase with framework code (angular) I am using this module. When several errors are thrown and several stracktraces are requested in a short succession memory usage spikes absolutely out of control.

Expected Behavior

Should require a little bit less memory per error.

Current Behavior

Memory spikes out of control. This is how stacktraces are requested.

    StackTrace.fromError(err)
      .then((stackframes) => {
        return stackframes
          .splice(0, 20)
          .map((sf) => {
            return sf.toString();
          }).join('\n');
      });

johannesjo avatar May 14 '20 16:05 johannesjo

@johannesjo would you mind attaching a snippet or unit test that would reproduce this issue so we could profile it.

niemyjski avatar Feb 24 '21 12:02 niemyjski

This line could be the culprit of high memory usage: https://github.com/stacktracejs/stacktrace.js/blob/c12fccdbf21b8ecf215b35474070da1b1c23206d/dist/stacktrace.js#L2527

A big source file will be splitted each time a function name must be found. Imagine what happen with a source file of 10Mb and a stacktrace with hundred of function names.

120318906-b29c9080-c2e0-11eb-8de1-d1fe6a88c055

lionelchauvin avatar Aug 04 '21 13:08 lionelchauvin

we have had browser crashes recently when using the stack trace grabbing functionality - as well as performance issues when gathering stack traces.

michaelAtCoalesce avatar Mar 04 '22 16:03 michaelAtCoalesce

Would you mind submitting a pr with a fix, perhaps info could be cached.

niemyjski avatar Mar 04 '22 18:03 niemyjski

i noticed that my .map file was 111megabytes, by reworking my webpack.config i was able to get it down to 1mb and i think that is helping reduce the amount of crashing thats going on.

to those in this boat, see if you can split your bundles to be smaller

https://medium.com/hackernoon/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758

michaelAtCoalesce avatar Apr 08 '22 04:04 michaelAtCoalesce