Build: Exhausted heap space, trying to allocate 34320487504 bytes.

Created on 21 Aug 2020  Â·  12Comments  Â·  Source: dart-lang/build

Precompiling executable...
Precompiled build_runner:build_runner.
[INFO] Generating build script...
[INFO] Generating build script completed, took 397ms

Exhausted heap space, trying to allocate 34320487504 bytes.

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues

Out of Memory
dart:core new _List
package:front_end/src/base/flat_buffers.dart 819:20 _FbGenericList.[]
package:analyzer/src/summary/package_bundle_reader.dart 425:44 SummaryDataStore.addBundle
package:analyzer/src/dart/sdk/sdk.dart 96:21 AbstractDartSdk.context
package:analyzer/src/context/context.dart 1975:46 PartitionManager.forSdk
package:analyzer/src/context/context.dart 744:50 AnalysisContextImpl.createCacheFromSourceFactory.createCache
package:analyzer/src/context/context.dart 749:38 AnalysisContextImpl.createCacheFromSourceFactory
package:analyzer/src/context/context.dart 476:14 AnalysisContextImpl.sourceFactory=
package:build_resolvers/src/resolver.dart 91:14 new AnalyzerResolver
package:build_resolvers/src/resolver.dart 435:32 new AnalyzerResolvers
package:build_runner_core/src/generate/options.dart 136:19 BuildOptions.create
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart TargetGraph.forPackageGraph
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart _packageBuildConfig
dart:async _completeOnAsyncReturn
package:build_config/src/build_config.dart BuildConfig.fromBuildConfigDir

pub finished with exit code 1

Most helpful comment

embarrassing
mb, updating the dependencies works for me

All 12 comments

@sunbowen920617 can you try --low-resources-mode? That flag is a more memory-efficient mode that does a lot less caching in memory.

It might be good to get a bit more information about your project though, do you possibly have a few very large files in your project which are a part of the build? It could be just that those files are being cached in memory and causing problems.

having the same issue. By the way, I am trying to understand the custom annotation by cloning this repo "https://github.com/jorgecoca/todo_reporter.dart". I got the issue when I was trying to run the build runner command.

@DayDreamer-commits did you try --low-resources-mode? Do you have large binary files in your project dir?

I'm having the same issue; same when using the --low-resources-flag
Tried it on this project which was referenced in a tutorial and supposedly has worked.

flutter --version

Flutter 1.22.0-2.0.pre.85 • channel master • https://github.com/flutter/flutter.git
Framework • revision 68c31d3d09 (2 hours ago) • 2020-08-26 19:34:03 +0100
Engine • revision 8ebeb03103
Tools • Dart 2.10.0 (build 2.10.0-59.0.dev)

What version of build_runner and analyzer are you using? Check with pub deps. What version of the SDK are you on?

There hasn't been a version of analyzer that uses package:front_end for a while. I don't know why package:front_end would try to allocate a 34GB List instance, but I wouldn't be too surprised if this bug doesn't surface in newer versions of analyzer.

:o
I'm getting

build_runner 0.10.3
analyzer 0.32.6

It's also pulling down front_end 0.1.4+2
Currently on Dart 2.10.0 (build 2.10.0-59.0.dev)

embarrassing
mb, updating the dependencies works for me

Interesting, I wonder if there is an issue with the old analyzer versions reading the new sdk summary file which causes this? That seems potentially likely - the summary file format did change at one point and possibly it changed in such a way that it somehow gets into an infinite loop when deserializing?

I don't know much about the flatbuffer format or whether that could be possible.

Note that for a while now we have been creating our own SDK summary file instead of using the one shipped with the SDK, for exactly this reason.

Note that I closed this issue under the assumption that upgrading fixes things, but feel free to comment if you are still having issues and we can re-open it.

I am getting the same error:

flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 348ms

Exhausted heap space, trying to allocate 34320316384 bytes.

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues

Out of Memory
dart:core new _List
package:analyzer/src/summary/flat_buffers.dart 819:20 _FbGenericList.[]
package:analyzer/src/summary/package_bundle_reader.dart 431:44 SummaryDataStore.addBundle
package:analyzer/src/dart/sdk/sdk.dart 94:21 AbstractDartSdk.context
package:analyzer/src/context/context.dart 1884:46 PartitionManager.forSdk
package:analyzer/src/context/context.dart 681:50 AnalysisContextImpl.createCacheFromSourceFactory.createCache
package:analyzer/src/context/context.dart 686:38 AnalysisContextImpl.createCacheFromSourceFactory
package:analyzer/src/context/context.dart 413:14 AnalysisContextImpl.sourceFactory=
package:build_resolvers/src/resolver.dart 95:14 new AnalyzerResolver
package:build_resolvers/src/resolver.dart 449:32 new AnalyzerResolvers
package:build_runner_core/src/generate/options.dart 132:19 BuildOptions.create
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart TargetGraph.forPackageGraph
dart:async _completeOnAsyncReturn
package:build_runner_core/src/package_graph/target_graph.dart _packageBuildConfig
dart:async _completeOnAsyncReturn
package:build_config/src/build_config.dart BuildConfig.fromBuildConfigDir

pub finished with exit code 1


Dart SDK 2.10.4
Flutter SDK 1.22.5
build_runner 1.2.3

@claudioafelix what is your analyzer version?

@claudioafelix what is your analyzer version?

Initially I was using 0.34.0, and tried to use the latest 0.41.1, that passed this error, but introduced another.

Now using 0.35.4 and it's working!!

Changed build_runner to version 1.9.0 as well!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hexer10 picture Hexer10  Â·  4Comments

Fjnova picture Fjnova  Â·  6Comments

natebosch picture natebosch  Â·  8Comments

kevmoo picture kevmoo  Â·  6Comments

MHamza600 picture MHamza600  Â·  4Comments