Skip to content

Any error during analysis will cause memory leak #15

@SuicaLondon

Description

@SuicaLondon

This ticket is relative to this issue but it has different behaviour and causes memory leak.
EEC3A631-B6BA-41DC-9412-56F530C7001A

I am currently using a MacBook Pro 14 inch with M1 Pro with 16G Ram, OS version is 14.1

If the analysis process encounters an error, such as the one mentioned, there may not be an apparent issue. However, problems may arise when committing a large number of files simultaneously, like during a 300-file refactoring. In such cases, the process might exhaust the computer's memory and continually create new Dart processes in the background. Upon investigating the code, I observed that the process fails to terminate in the event of an error [will not kill the process](https://github.com/hyiso/lint_staged/blob/main/lib/s
Screenshot 2024-01-27 at 19 13 57
rc/run.dart).

What I suggest is that, add the kill process code on error handling as the Flutter does not have feature of Future.allSettled()

 if (result.stderr.toString().trim().isNotEmpty) {
          messsages.add(red(result.stderr.toString().trim()));
          Process.killPid(result.pid); // Kill process here
}
if (result.stdout.toString().trim().isNotEmpty) {
          messsages.add(result.stdout.toString().trim());
}
        _verbose(messsages.join('\n'));
 if (result.exitCode != 0) {
          ctx.output.add(messsages.join('\n'));
          ctx.errors.add(kTaskError);
          Process.killPid(result.pid); // Kill process here
 }

As I'm uncertain about the business logic, this may not work as the message does not update. So it seems the issue could be attributed to the process not terminating properly, causing it to stay in the memory forever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions