schultek/dart_mappable

Out of Memory for build runner

Opened this issue · 4 comments

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

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

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.

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.

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