0

I have been facing issues when I run the 'flutter build apk' command on my laptop. Below attached is the stack trace output for the command. Any help would be greatly appreciated. I am running the latest version of Flutter 3.7.5 and the apk is failing to build and is showing memory issues even though I have plenty of available space on my system.

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Exhausted heap space, trying to allocate 240 bytes.
../../third_party/dart/runtime/vm/object.cc: 2803: error: Out of memory.
version=2.19.2 (stable) (Tue Feb 7 18:37:17 2023 +0000) on "macos_simarm64"
pid=30980, thread=-1, isolate_group=isolate(0x7fb700804200), isolate=isolate(0x7fb700809400)
os=macos, arch=arm64, comp=yes, sim=yes
isolate_instructions=0, vm_instructions=0
  pc 0x000000010dad9975 fp 0x00007fff522be250 dart::Profiler::DumpStackTrace(void*)+0x85
  pc 0x000000010d94a334 fp 0x00007fff522be330 dart::Assert::Fail(char const*, ...) const+0x84
  pc 0x000000010da5a482 fp 0x00007fff522be380 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x132
  pc 0x000000010da89daf fp 0x00007fff522be3c0 dart::Instructions::New(long, bool)+0x4f
  pc 0x000000010da90612 fp 0x00007fff522be440 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xa2
  pc 0x000000010da909ba fp 0x00007fff522be460 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x2a
  pc 0x000000010db45cba fp 0x00007fff522be600 dart::StubCode::GetBuildMethodExtractorStub(dart::compiler::ObjectPoolBuilder*, bool)+0x15a
  pc 0x000000010d9e6f1c fp 0x00007fff522bebe0 dart::Dart::InitializeIsolate(unsigned char const*, unsigned char const*, unsigned char const*, long, dart::IsolateGroup*, void*)+0x49c
  pc 0x000000010de04392 fp 0x00007fff522bf110 dart::CreateIsolate(dart::IsolateGroup*, bool, char const*, void*, char**)+0xc2
  pc 0x000000010de048d8 fp 0x00007fff522bf1e0 Dart_CreateIsolateGroupFromKernel+0x1b8
  pc 0x000000010d941dc4 fp 0x00007fff522bf380 dart::bin::main(int, char**)+0x824
  pc 0x00007fff9fe66235 fp 0x00007fff522bf390 start+0x1
-- End of DumpStackTrace
Exhausted heap space, trying to allocate 240 bytes.
../../third_party/dart/runtime/vm/object.cc: 2803: error: Out of memory.
version=2.19.2 (stable) (Tue Feb 7 18:37:17 2023 +0000) on "macos_arm"
pid=30979, thread=-1, isolate_group=isolate(0x7feb1f000800), isolate=isolate(0x7feb21000000)
os=macos, arch=arm, comp=no, sim=no
isolate_instructions=0, vm_instructions=0
Exhausted heap space, trying to allocate 208 bytes.
../../third_party/dart/runtime/vm/object.cc: 2803: error: Out of memory.
version=2.19.2 (stable) (Tue Feb 7 18:37:17 2023 +0000) on "macos_x64"
pid=30981, thread=-1, isolate_group=isolate(0x7fa292801000), isolate=isolate(0x7fa292806600)
os=macos, arch=x64, comp=yes, sim=no
isolate_instructions=0, vm_instructions=0
  pc 0x0000000102aeb3a5 fp 0x00007fff5d29d210 dart::Profiler::DumpStackTrace(void*)+0x85
  pc 0x000000010296b334 fp 0x00007fff5d29d2f0 dart::Assert::Fail(char const*, ...) const+0x84
  pc 0x0000000102a76642 fp 0x00007fff5d29d340 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x122
  pc 0x0000000102aa014f fp 0x00007fff5d29d380 dart::Instructions::New(long, bool)+0x4f
  pc 0x0000000102aa67e2 fp 0x00007fff5d29d400 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xa2
  pc 0x0000000102aa6b6a fp 0x00007fff5d29d420 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x2a
  pc 0x0000000102b4ab4a fp 0x00007fff5d29d5c0 dart::StubCode::GetBuildMethodExtractorStub(dart::compiler::ObjectPoolBuilder*, bool)+0x15a
  pc 0x0000000102a04abc fp 0x00007fff5d29dba0 dart::Dart::InitializeIsolate(unsigned char const*, unsigned char const*, unsigned char const*, long, dart::IsolateGroup*, void*)+0x43c
  pc 0x0000000102e02a62 fp 0x00007fff5d29e0d0 dart::CreateIsolate(dart::IsolateGroup*, bool, char const*, void*, char**)+0xc2
  pc 0x0000000102e02f98 fp 0x00007fff5d29e1a0 Dart_CreateIsolateGroupFromKernel+0x1b8
  pc 0x0000000102962dc4 fp 0x00007fff5d29e340 dart::bin::main(int, char**)+0x824
  pc 0x00007fff9fe66235 fp 0x00007fff5d29e358 start+0x1
-- End of DumpStackTrace
  pc 0x000000010737d895 fp 0x00007fff58a1a250 dart::Profiler::DumpStackTrace(void*)+0x85
  pc 0x00000001071ee334 fp 0x00007fff58a1a330 dart::Assert::Fail(char const*, ...) const+0x84
  pc 0x00000001072fe302 fp 0x00007fff58a1a380 dart::Object::Allocate(long, long, dart::Heap::Space, bool)+0x132
  pc 0x000000010732dc2f fp 0x00007fff58a1a3c0 dart::Instructions::New(long, bool)+0x4f
  pc 0x0000000107334582 fp 0x00007fff58a1a440 dart::Code::FinalizeCode(dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0xa2
  pc 0x000000010733492a fp 0x00007fff58a1a460 dart::Code::FinalizeCodeAndNotify(char const*, dart::FlowGraphCompiler*, dart::compiler::Assembler*, dart::Code::PoolAttachment, bool, dart::CodeStatistics*)+0x2a
  pc 0x00000001073debea fp 0x00007fff58a1a600 dart::StubCode::GetBuildMethodExtractorStub(dart::compiler::ObjectPoolBuilder*, bool)+0x15a
  pc 0x000000010728b41c fp 0x00007fff58a1abe0 dart::Dart::InitializeIsolate(unsigned char const*, unsigned char const*, unsigned char const*, long, dart::IsolateGroup*, void*)+0x49c
  pc 0x00000001076a52f2 fp 0x00007fff58a1b110 dart::CreateIsolate(dart::IsolateGroup*, bool, char const*, void*, char**)+0xc2
  pc 0x00000001076a5838 fp 0x00007fff58a1b1e0 Dart_CreateIsolateGroupFromKernel+0x1b8
  pc 0x00000001071e5dc4 fp 0x00007fff58a1b380 dart::bin::main(int, char**)+0x824
  pc 0x00007fff9fe66235 fp 0x00007fff58a1b398 start+0x1
-- End of DumpStackTrace
Dart snapshot generator failed with exit code -6
Dart snapshot generator failed with exit code -6
Dart snapshot generator failed with exit code -6
Target android_aot_release_android-arm64 failed: Exception: AOT snapshotter exited with code -6
Target android_aot_release_android-arm failed: Exception: AOT snapshotter exited with code -6
Target android_aot_release_android-x64 failed: Exception: AOT snapshotter exited with code -6


FAILURE: Build failed with an exception.

* Where:
Script '/Users/bigwelt/Downloads/developer/flutter2/packages/flutter_tools/gradle/flutter.gradle' line: 1151

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/bigwelt/Downloads/developer/flutter2/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 46s
Syed A.R
  • 159
  • 1
  • 9
  • Can you please try solutions here: https://stackoverflow.com/questions/61674754/flutter-exhausted-heap-space-trying-to-allocate-8589934608-bytes-and-laptop-st – Steve Feb 27 '23 at 10:53
  • I have tried the solutions found on stackoverflow so far and none of them seem to be working for me. – Syed A.R Feb 27 '23 at 10:59

0 Answers0