invertase / dart_custom_lint

💡 Easily write powerful Dart & Flutter lint rules for your projects or for users of your packages.
https://pub.dev/packages/custom_lint
Apache License 2.0
288 stars 65 forks source link

(Possible) Memory Leaks #248

Open MichaelDarkMostIo opened 6 months ago

MichaelDarkMostIo commented 6 months ago

It looks like custom_lint_client process is consuming more RAM than the whole analysis_server.

Screenshot 2024-05-07 at 13 58 51

Not sure what kind of related info I should provide for the issue, but it must be either a lack of optimization or memory leaks problem.

EArminjon commented 5 months ago

Got same observation, didn't know why but when enabling this plugin i got a lot heavy CPU usage.

include: package:lint/analysis_options.yaml

custom_lint:
  enable_all_lint_rules: false
  rules:
    - use_design_system_item:
      AppExpansionPanel:
        - instead_of: ExpansionPanelList
          from_package: flutter

analyzer:
  plugins:
    - custom_lint
  errors:
    missing_required_param: error
    missing_return: error
    todo: ignore
    parameter_assignments: warning
    invalid_annotation_target: ignore
    unnecessary_constructor_name: true
  exclude:
    - lib/**/generated/**
    - test/**/generated/**
    - forked/
    - test/tmp/**

linter:
  rules:
    always_put_control_body_on_new_line: false
    always_put_required_named_parameters_first: true
    always_specify_types: true
    always_use_package_imports: false
    avoid_equals_and_hash_code_on_mutable_classes: true
    avoid_redundant_argument_values: false
    avoid_relative_lib_imports: false
    avoid_renaming_method_parameters: true
    avoid_returning_this: true
    constant_identifier_names: false
    flutter_style_todos: true
    no_default_cases: true
    no_wildcard_variable_uses: false
    overridden_fields: false
    prefer_asserts_with_message: true
    prefer_const_constructors: true
    prefer_const_constructors_in_immutables: true
    prefer_const_declarations: true
    prefer_const_literals_to_create_immutables: true
    prefer_constructors_over_static_methods: true
    prefer_relative_imports: true
    prefer_spread_collections: true
    prefer_single_quotes: true
    sort_child_properties_last: true
    sort_pub_dependencies: false
    sized_box_for_whitespace: true
    sized_box_shrink_expand: true
    unawaited_futures: true
    unnecessary_const: true
    use_colored_box: true
    use_decorated_box: true
    use_enums: true
    use_key_in_widget_constructors: true
    use_named_constants: true
    use_super_parameters: true
    use_to_and_as_if_applicable: true
victor-tinoco commented 5 months ago

I'm running the same as well. This consumes the CPU and slows my laptop down in a way I'm kinda obligated to open the Activity Monitor and just kill it all the time.

victorcatn commented 4 months ago

This issue was slowing significantly my IDE, just navigating with cmd+clic was taking tens of seconds and saving dart files was taking minutes if not crashing. It happened in multiple projects using custom_lint and riverpod_lints. I tried with a new computer and a clean SO + Flutter install and the issue happened again. I also tried switching from VScode to Android Studio but the flutter outline and dart refactors stopped working after a few seconds of use and become unusable, after disabling custom_lint it works normally For now I had to disable custom_lint in all my projects to get a normal development flow

amrgetment commented 4 months ago

I confirmed same issue but it wasn’t there 1 month ago

rrousselGit commented 4 months ago

Do you have any error in the custom_lint.log or something?

amrgetment commented 4 months ago

No errors, I use those linters:

dev_dependencies:
  # Linters
  flutter_lints: ^4.0.0
  autoclose_lint: ^1.0.2
  custom_lint: ^0.6.4
  freezed_lint: ^0.0.2
  solid_lints: ^0.1.5

I use prefer_match_file_name from solid_lints but I don’t think it is related to the memory issue, and once I disable

 # plugins:
 #  - custom_lint

no memory issues after disabling

analysis_options.yaml.zip

amrgetment commented 4 months ago

I will activate it again and I will let you know if I got errors

rrousselGit commented 4 months ago

For what it's worth, I'm making significant changes to support analyzer 6.5.0. Hopefully this should get better.

Still, in terms of memory, it's always going to consume quite a bit.

Anyway note that the memory issue could be coming from a specific plugin. For instance, it could be that riverpod_lint is the problem. I could see how that happens, as it does a lot of caching.

amrgetment commented 4 months ago

macros will improve build_runners what would be the feature in the dart that could improve the analyzer?

rrousselGit commented 4 months ago

Not a Dart feature but an analyzer feature. Plugins are getting a rework to solve memory issues.

EArminjon commented 4 months ago

What about CPU usage 👀 ? (I can open a new GitHub issue)

Thanks for your amazing package ❤️

rrousselGit commented 4 months ago

Depends. Note that there could always be a bug in any of the packages.

For example I'm aware of at least one performance issue caused by some form of delayed infinite loop in riverpod_lint. I'm working on fixing this at the moment.