Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"exhausted heap space, trying to allocate ..." during auto generate *.g.dart files #2559

Closed
flimuti opened this issue Nov 22, 2019 · 10 comments

Comments

@flimuti
Copy link

flimuti commented Nov 22, 2019

Hello, I'm trying to auto-generate the *.g.dart file using build_runner package command, but the command ends with a series of "Exhausted heap space, trying to allocate.." messages.
The command I've used is
flutter packages pub run build_runner build
The other build_runner commands have also the same result.
I browsed for the problem on the Internet (git, stackoverflow, etc.) but I didn't find any solution.
Do you have any suggestions or solutions? Thanks!

Dart SDK Version : 2.5.0
package from this repo I'm using and the version: build_runner 1.6.5
IDE: VS code on Windows

@jakemac53
Copy link
Contributor

What builders are you using? Most likely one of them has a bug.

@flimuti
Copy link
Author

flimuti commented Nov 25, 2019

I don't think it's a bug because some months ago the command run successfully. My colleague also uses the same build_runner version without problems

@natebosch
Copy link
Member

I think there had been a change that limited the heap size of the VM somewhat recently. Although, based on dart-lang/sdk#27883 (comment) that change may have only affected linux.

If the build had been using a high amount of heap space before a change to add a limit in the SDK could cause it to start failing.

Can you check how much memory the build process uses before it fails?

In the short term you could check if the --low-resources-mode flag helps.

@flimuti
Copy link
Author

flimuti commented Nov 26, 2019

The --low-resources-mode flag doesn't help, the build process ends with the same result.
Before it fails the build process uses about 15.5 GB of memory.
I've just tryed to run again the command and the stack trace now is

flutter packages pub run build_runner build
Exhausted heap space, trying to allocate 14768 bytes.
Crash when formatting: [Encoding] Unable to decode bytes as UTF-8.
Out of Memory
#0      _StringBase._concatRangeNative (dart:core-patch/string_patch.dart:946:34)
#1      _StringBase._interpolate (dart:core-patch/string_patch.dart:860:16)
#2      formatErrorMessage (package:front_end/src/fasta/command_line_reporting.dart:132:43)
#3      format (package:front_end/src/fasta/command_line_reporting.dart:87:14)
#4      ProcessedOptions.format (package:front_end/src/base/processed_options.dart:203:9)
#5      ProcessedOptions.report (package:front_end/src/base/processed_options.dart:224:29)
#6      Loader.addMessage (package:front_end/src/fasta/loader.dart:71:3)
#7      SourceLibraryBuilder.addProblem (package:front_end/src/fasta/source/source_library_builder.dart:317:26)
#8      SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart:244:17)
#9      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#10     _rootRunUnary (dart:async/zone.dart:1132:38)
#11     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#12     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#13     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#14     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#15     Future._completeWithValue (dart:async/future_impl.dart:522:5)
#16     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#17     _rootRun (dart:async/zone.dart:1124:13)
#18     _CustomZone.run (dart:async/zone.dart:1021:19)
#19     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#22     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
#23     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#24     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

Exhausted heap space, trying to allocate 65568 bytes.
Unable to spawn isolate: Out of Memory
#0      new _List (dart:core-patch/array.dart)
#1      StringCanonicalizer.clear (package:front_end/src/fasta/scanner/string_canonicalizer.dart:120:18)
#2      CompilerContext.clear (package:front_end/src/fasta/compiler_context.dart:148:31)
#3      _rootRun (dart:async/zone.dart:1120:38)
#4      _CustomZone.run (dart:async/zone.dart:1021:19)
#5      _FutureListener.handleWhenComplete (dart:async/future_impl.dart:161:18)
#6      Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:648:39)
#7      Future._propagateToListeners (dart:async/future_impl.dart:704:37)
#8      Future._completeError (dart:async/future_impl.dart:530:5)
#9      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:36:15)
#10     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart)
#11     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:78:45)
#12     _rootRunBinary (dart:async/zone.dart:1144:38)
#13     _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#14     _FutureListener.handleError (dart:async/future_impl.dart:151:20)
#15     Future._propagateToListeners.handleError (dart:async/future_impl.dart:690:47)
#16     Future._propagateToListeners (dart:async/future_impl.dart:711:24)
#17     Future._completeError (dart:async/future_impl.dart:530:5)
#18     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:36:15)
#19     withCrashReporting (package:front_end/src/fasta/crash.dart)
#20     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:78:45)
#21     _rootRunBinary (dart:async/zone.dart:1144:38)
#22     _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#23     _FutureListener.handleError (dart:async/future_impl.dart:151:20)
#24     Future._propagateToListeners.handleError (dart:async/future_impl.dart:690:47)
#25     Future._propagateToListeners (dart:async/future_impl.dart:711:24)
#26     Future._completeError (dart:async/future_impl.dart:530:5)
#27     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:36:15)
#28     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart)
#29     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:78:45)
#30     _rootRunBinary (dart:async/zone.dart:1144:38)
#31     _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#32     _FutureListener.handleError (dart:async/future_impl.dart:151:20)
#33     Future._propagateToListeners.handleError (dart:async/future_impl.dart:690:47)
#34     Future._propagateToListeners (dart:async/future_impl.dart:711:24)
#35     Future._completeError (dart:async/future_impl.dart:530:5)
...
...
#59     Loader.buildOutlines (package:front_end/src/fasta/loader.dart)
#60     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:78:45)
#61     _rootRunBinary (dart:async/zone.dart:1144:38)
#62     _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#63     _FutureListener.handleError (dart:async/future_impl.dart:151:20)
#64     Future._propagateToListeners.handleError (dart:async/future_impl.dart:690:47)
#65     Future._propagateToListeners (dart:async/future_impl.dart:711:24)
#66     Future._completeError (dart:async/future_impl.dart:530:5)
#67     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:36:15)
#68     SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart)
#69     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:78:45)
#70     _rootRunBinary (dart:async/zone.dart:1144:38)
#71     _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#72     _FutureListener.handleError (dart:async/future_impl.dart:151:20)
#73     Future._propagateToListeners.handleError (dart:async/future_impl.dart:690:47)
#74     Future._propagateToListeners (dart:async/future_impl.dart:711:24)
#75     Future._completeError (dart:async/future_impl.dart:530:5)
#76     _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:36:15)
#77     SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart)
#78     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#79     _rootRunUnary (dart:async/zone.dart:1132:38)
#80     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#81     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#82     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#83     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#84     Future._completeWithValue (dart:async/future_impl.dart:522:5)
#85     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#86     _rootRun (dart:async/zone.dart:1124:13)
#87     _CustomZone.run (dart:async/zone.dart:1021:19)
#88     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#89     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#90     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#91     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
#92     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#93     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
pub finished with exit code 1

@natebosch
Copy link
Member

Before it fails the build process uses about 15.5 GB of memory.

Is that about what is available on your computer? If it is this might be because of a memory leak somewhere that was recently introduced. If your computer has more memory than that it's a signal that the VM might be setting an artificially low limit.

@flimuti
Copy link
Author

flimuti commented Nov 27, 2019

When the build process fails, 8.4 GB of memory are still available.
In any case, if I run the command on my colleague's computer, the build process doesn't need this amount of memory. It uses a maximum of 350 MB of memory, so I don't understand why running the process on my computer it uses 15.5 GB of memory.

@natebosch
Copy link
Member

In any case, if I run the command on my colleague's computer, the build process doesn't need this amount of memory.

That points strongly to a memory leak in one of the builders you are using. Maybe in a specific version of the builder package.

@adityaoswal77
Copy link

adityaoswal77 commented May 18, 2020

In any case, if I run the command on my colleague's computer, the build process doesn't need this amount of memory.

That points strongly to a memory leak in one of the builders you are using. Maybe in a specific version of the builder package.

How do i resolve this?
Because i am facing a similar issue.
And it is only a simple main.dart program

Here is the program:
`
import 'package:flutter/material.dart';

void main() {
runApp(
MaterialApp(
home: Center(
child: Text('Hello'),),),);
}
`
This is the error :

Running Gradle task 'assembleDebug'... Exhausted heap space, trying to allocate 17179869200 bytes.

@jakemac53
Copy link
Contributor

@adityaoswal77 that looks unrelated to the this repo, and more a general flutter issue.

@jakemac53
Copy link
Contributor

I am going to close this issue as it is quite stale, we can re-open if we get some actionable information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants