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](https://private-user-images.githubusercontent.com/11754414/333867156-7bc69851-1aa7-4ec8-a2dc-bf9a1ad59172.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUwMjU5NzksIm5iZiI6MTcyNTAyNTY3OSwicGF0aCI6Ii8xMTc1NDQxNC8zMzM4NjcxNTYtN2JjNjk4NTEtMWFhNy00ZWM4LWEyZGMtYmY5YTFhZDU5MTcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODMwVDEzNDc1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI2NzUwYjIxZTEwMjNhMDE0Mzc5NTIzODdhNjE3OWE4ODM3YWZiOTIxMjliZjUyMmQwMDk0YzI0NGQ4ZjRjYjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WpiBDiY0o3j6D7mkHqUbPkm6f7jL6yv_T4SUuwc0iXg)
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