schultek / dart_mappable

Improved json serialization and data classes with full support for generics, inheritance, customization and more.
https://pub.dev/packages/dart_mappable
MIT License
135 stars 20 forks source link

Out of Memory for build runner #197

Open tsherdiwala opened 1 month ago

tsherdiwala commented 1 month ago

When running dart_mappable for across the project generation - the memory footprint grows extensively and leading to almost 30GB of usage.

Have made sure that only the dart_mappable_builder builder is initiated by disabling the other builders using build.yaml file.

Upon running the debugger tools able to see that the memory is being hogged and not being garbage collect with package:analyzer/src/dart/element/element.dart/ParameterElementImpl being the one holding the highest memory

image
schultek commented 1 month ago

I will try to investigate. What would help if you have a reproducible setup that causes this.

tsherdiwala commented 1 month ago

I can try to create a subset of the things which I am working on as won't be able to share the actual code base. However the point to highlight is that there are many classes / files which rely extensively on it. On a smaller usecase it works however probably when there is a large number of generations to take place that were the issue happens.

schultek commented 1 month ago

I wonder if thats just a linear scaling problem (more classes to more memory) or an exponentially scaling problem because of some bug. But the high numbers point to some memory leak.

tsherdiwala commented 1 month ago

I have as of now found a workaround by limiting the files using build.yaml and selectively enabling it.

eg:

targets:
  $default:
    builders:
      build_resolvers:transitive_digests:
        enabled: false
      reflectable:
        enabled: false
      dart_mappable_builder:
        enabled: true
        generate_for:
          include:
#            - lib/**analytics.dart
#            - lib/**ViewModel.dart
#            - lib/**app.dart
#            - lib/**legacy.dart
#            - lib/**notifications.dart
#            - lib/**ad.dart
#            - lib/**ViewModelProps.dart
#            - lib/**constants.dart
#            - lib/**ViewModelState.dart
            - lib/**serialization.dart
#          exclude:
#            - lib/**.*.dart
      freezed:
        enabled: true